Will the monobehaviour functions be called if the class is not an object?

Okay, so the question needs some explaining.

I am currently making a spellsystem. I have a baseclass with the necesarry things for a spell like cooldown and what button to press to use the spell. This inherits from MonoBehaviour. I also have multiple subclasses with different spells like fireball etc. These inherit from the base spellclass.

I also have a spellmanager. Within this I plan to have an array of size 4, that will be populated with the spells. I was wondering if MonoBehaviour will still call the functions in these classes like Update, even though they are not components added to the GameObject?

Also, if you have a better suggestion for managing the spells, it would be greatly appreciated!

1 Answer

1

No the functions will not be called. MonoBehaviours are designed to be a components on game objects. I cannot think of a good reason to inherit from MonoBehaviour and then create your objects using the ‘new’ operator.

What he said. You can always make a wrapper class that does get attached to a GameObject that fires off the events to your non MonoBehaviour classes.