Answers for "You are trying to create a MonoBehaviour using the 'new' keyword."

C#
0

unity you are trying to create a monobehaviour using the 'new' keyword

// Instead of this:
 MyScript script = new Script();
 // Do this:
 MyScript script = obj.AddComponent<MyScript>();
Posted by: Guest on February-07-2021
0

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

DetectPlayer dp;

private void Awake()
{
    GameObject gameObject = new GameObject("DetectPlayer");
    dp = gameObject.AddComponent<DetectPlayer>();
}
Posted by: Guest on August-26-2021

Code answers related to "You are trying to create a MonoBehaviour using the 'new' keyword."

C# Answers by Framework

Browse Popular Code Answers by Language