I'm a beginner developing games on Unity3D and now that I've become a little bit familiar with GameManagers I've been wondering about certain aspects.

How do you contruct a GameManager in the most efficient way? Since it's an entity that persists through scene loads, it has to be tweaked to reset some values on level load because it doesn't do that by itself.

I'm making a 2D platformer, so when a new level is loaded (or the current level is restarted) the GameManager has to dynamically find references to the objects it handles. And because each level cannot be identical to the next, should I have code in the GameManager to find references to the specific GameObjects and values depending on the level? I'm thinking something like this:

public class GameManager : MonoBehaviour {

  //Values and core methods etc

  void OnLevelWasLoaded(int level) {
    if (level == 1) {
      //Find references and set values for level 1
    if (level == 2) {
      //Find references and set values for level 2

Or should I have a separate GameManager for values, game states and events and an in-between script for handling the GameObject references? I just want to learn this right. I'm worrying that if I dump "everything" in the GameManager, it becomes too big and inefficient.

Speaking of which, is it OK for the GameManager to also handle the UI/HUD? Or should there be a separate UIManager dedicated for this task?


1 Answer 1


UI and HUD is better managed elsewhere. the GameManager is supposed to manage the game state and transitions between game states and nothing else. Possible states could be title, menu, loading or ingame. Note that there are not states for every level like levelXY.

See the scene/level as the data for a state. You might come into a situation where need to specialise for certain levels like having state for carchase or indoor. You will have a persistent game object that holds the GameManager and other managers. Keep in mind that it must be a singleton or you will end up with multiple GameManagers.

Additional managers could handle music so you could have music playing during game state transitions.

  • \$\begingroup\$ Ah, thanks for the advice! I must have misunderstood the concept. So basically there needs to be a separate level manager? And that it's altogether more efficient to have separate managers for all things that need managing. \$\endgroup\$
    – jonraem
    Commented Dec 9, 2014 at 16:04
  • \$\begingroup\$ @yotara Depends on the complexity of your levels or game. It may be sufficent if every level by itself knows what level comes next. Information what level comes next could also be data in doors or exits. There might be no need for a level manager. \$\endgroup\$
    – aggsol
    Commented Dec 10, 2014 at 8:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .