I wish to instantiate a class inherite from MonoBehaviour class in a similar way than the example bellow.
Is there a way to do it without getting the warning message (“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”).
public classe Test : MonoBehaviour
{
Move move = newMove();
void Update()
{
move.Printing ();
}
}
public class Move : MonoBehaviour
{
public int number = 5;
public void Printing()
{
print(number);
}
}
thank you.