Unity3D脚本编写错误汇集
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed.
1 using UnityEngine; 2 3 namespace Assets 4 { 5 public abstract class AbstractRotaryMovement:MonoBehaviour 6 { 7 public abstract void Whirling(GameObject gameObject,float x,float y,float z); 8 } 9 }
1 using System.Threading.Tasks; 2 using UnityEngine; 3 4 namespace Assets 5 { 6 public class ConcreteRotaryMovement3D: AbstractRotaryMovement 7 { 8 public override void Whirling(GameObject gameObject,float x,float y,float z) 9 { 10 gameObject.transform.eulerAngles = new Vector3(x, y, z); 11 } 12 public int Hh() 13 { 14 return 22; 15 }
1 using UnityEngine; 2 using System.Configuration; 3 using System.Reflection; 4 using System; 5 6 public class MoveControl : MonoBehaviour 7 { 8 public ConcreteRotaryMovement3D concreteRotaryMovement3D = new ConcreteRotaryMovement3D(); 9 public TextClass textClass; 10 // Start is called before the first frame update 11 void Start() 12 { 13 14 }
继承自MonoBehaviour的类,不允许被实例化