Answer the question
In order to leave comments, you need to log in
Why is the class constructor not supported in the unit?
Why is the constructor not supported in the unit? Are inheritance and polymorphism supported?
Answer the question
In order to leave comments, you need to log in
Everything is supported. And the constructor, and inheritance, and polymorphism. The current for MonoBehaviour is slightly different rules - there is Start / Awake.
For classes that inherit from MonoBehaviour, it's best not to use a constructor. First, it will also be called in the inspector before the game starts. Secondly, after starting it will be called twice, I don’t know what this is connected with, but that’s not the point. As you have already been told, you need to use Start / Awake. And to create heirs of the MonoBehaviour class, use AddComponent to "attach" to an object and Instantiate to create objects. On their own, without being used in the scene, these classes should not exist.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question