ロバメモ - 素人のUnity覚書と奮闘記

素人のUnity覚書と奮闘記

Error : You are trying to create a MonoBehaviour using the 'new' keyword.

You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all

MonoBehaviorを継承したクラスは、コンストラクターじゃなくて、ゲームオブジェクトにアタッチして使うようにしてね。
ということらしい。

MyClass my_class = new MyClass();

↓ 

MyClass my_class = GetComponent<MyClass>();

以上。