Skip to content

Instantly share code, notes, and snippets.

@elct9620
Last active August 16, 2018 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elct9620/037670a98f85413cb143530dddc9cff6 to your computer and use it in GitHub Desktop.
Save elct9620/037670a98f85413cb143530dddc9cff6 to your computer and use it in GitHub Desktop.
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();
}
}
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