Hi, I have to create an Array with contains a few classes which based on Monobehaviour.
This is the code I’m using:
Object[] scripts = new Object[]{Flare, Knife, Speer};
Now I get a warning everytime I start the game:
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
I know that a Monobehaviour script has to be attached to a GameObject and can be referenced from there, but now I have a few questions.
- Is there a way to use Monobehaviour without a GameObject?
- What can happen if I ignore the warning?
- Can I just replace Monobehaviour with ScriptableObject?
Thanks for help!