Last active
August 16, 2018 16:04
-
-
Save elct9620/037670a98f85413cb143530dddc9cff6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class GameInstance { | |
// Core Game Module | |
private Player.Controller _playerController; | |
public Player.Controller PlayerController { | |
retrun _playerController; | |
} | |
public GameInstance() { | |
// ... | |
} | |
public Init() { | |
if(_playerController == null) { | |
_playerController = new Player.Controller(); | |
} | |
// etc ... | |
} | |
} | |
// Attach to GameObject in each scene | |
public class GameManager : MonoBehavior { | |
private static GameInstance _instance; | |
public static GameInstance Instance { | |
get { | |
if (_instance == null) { | |
_instance = new GameInstance(); | |
} | |
return _instance; | |
} | |
} | |
void Start() { | |
Instance.Init(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GameManger { | |
private GameManager() { | |
// ... | |
} | |
private static GameManager _instance; | |
public static GameManager Instance() { | |
if (_instance == null) { | |
_instance = new GameManager(); | |
} | |
return _instance; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment