private void Awake() { if (instance == null) { instance = this; } else if (instance != null) { Destroy(gameObject); } }
public void Awake() { if (Instance == null) { Instance = this; } else if (Instance != null) { Destroy(gameObject); } /* Don't destroy when reloading the scene */ DontDestroyOnLoad(gameObject); // Load singletons _gameStateManager = gameObject.AddComponent <GameStateManager>(); _levelManager = gameObject.AddComponent <LevelManager>(); _upgradeManager = gameObject.AddComponent <UpgradeManager>(); // Load external components _playerController = GameObject.Find("Player").GetComponent <PlayerController>(); }