Hi all, I have a couple of objects that basically won’t change (won’t get destroyed, or altered) during game play.
These objects are for example - AudioManager, GameControler, PlayersClonesContainer, and so on. Is it a good idea to make them static?
Each of this objects has it’s own script attached, eg. AudioManager_scr, GameControler_scr, etc. Can I make variables contained within those scripts static? Provided they won’t change during the game. Come to think of it…shouldn’t I make them constants?
Generally Managers are full objects that are implemented through a singleton pattern, because of how unity works, the singleton pattern needs to be modified to use unity’s state machine methods such as Awake, Start, etc.
Unify Community has a couple entries you may want to look at:
The singleton pattern allows you to setup static classes that inherit from MonoBehaviour that can be attached to GameObjects and use the same instance of that class. These objects can be marked with DontDestroyOnLoad to ensure they transcend scenes and retain their various values/properties/etc.