Hello all,
I started working with Unity about a week ago. I have been doing C#/.NET/WPF programming for the last 2 years or so. As such, I became accustomed to a general “correct” way of programming, at least in WPF (SOLID principles, binding, MVVM, etc.).
Now in Unity, things seem a little more, ambiguous? As in, there are many more accepted ways of designing. Probably because many games can be so different from each other. It has been a little overwhelming. I have navigated various tutorials and documentation to try and find some type of structure but am still a little lost in places.
So I just wanted to break down some general game structure questions I have about scripting in Unity. Given a basic game structure with a Main Menu that may have several options like Play, Options, Shop. And then a Game Scene that cycles through “Stages” with breaks in between:
-
What is the best way to use a “GameManager” class?
-
Is that best to keep track of persisting properties like the Player’s Gold and Level, etc. and reload or switch Scenes.
-
Something like that is usually used in so many different places like when you defeat a monster, or purchase an item, so is creating a persistent singleton GameManager class that just follows Scene-to-Scene which other classes reference the way to go?
-
Should a GameManager know about Labels (like Gold, XP) and send the values to the GUI? Or is there a better way of doing that?
-
What do breaks between stages typically look like? Is it a UI element that you pop on screen until the User is ready to move on?
-
When creating multiple enemies or something of the sort, should you create multiple prefabs with adjustable properties (from Scripts) like Health, Attack, etc? And just switch out SpriteRenderers? I have seen some people use the SpriteRenderer as a Script property and keep the prefabs more general. But that seems a little more annoying.
I tried to keep the questions pretty general - I believe most of these apply to a lot of typical game structures. There still may be differing opinions on this stuff, but I’m hoping for some type of consensus so I’m not outright developing with poor practices. Thanks in advance!