protected override void Awake() { base.Awake(); gameRunning.onLockStateChange += GameRunning_onLockStateChange; PersistentLoader.LoadIfNotLoaded(InitGame); }
void Start() { if (loadOnStart) { PersistentLoader.LoadIfNotLoaded(Load); } else { PersistentLoader.LoadIfNotLoaded(); } }
private void Awake() { if (Instance == null) //If there are no other instances of this object { Instance = this; //Set this to the Instance DontDestroyOnLoad(gameObject); //Don't destroy } else //If there ARE other instances of this object { Destroy(gameObject); //Destroy them } }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); queue = new InitQueue(() => { //On complete for (int i = 0; i < callbacks.Count; i++) { callbacks[i](); } callbacks = null; }); for (int i = 0; i < persistentObjects.Count; i++) { if (persistentObjects[i] == null) { continue; } IPersistent manager = persistentObjects[i] as IPersistent; if (manager != null) { persistentObjects[i] = manager.DuplicationBehavior(); manager = persistentObjects[i] as IPersistent; //Init manager.Init(queue.Register()); } } queue.MarkEnd(); }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); queue = new InitQueue(() => { //On complete for (int i = 0; i < callbacks.Count; i++) { callbacks[i](); } callbacks = null; }); for (int i = 0; i < persistentObjects.Count; i++) { if (persistentObjects[i] == null) { continue; } IPersistent manager = persistentObjects[i] as IPersistent; if (manager != null) { string name = persistentObjects[i].name; pendingObjects.Add(name); persistentObjects[i] = manager.DuplicationBehavior(); manager = persistentObjects[i] as IPersistent; Action registeration = queue.Register(); //Init manager.Init(() => { pendingObjects.Remove(name); registeration(); }); } } queue.MarkEnd(); this.DelayedCall(() => { if (!queue.IsOver) { Debug.Log("A manager is taking an abnormally long time to initialize."); for (int i = 0; i < pendingObjects.Count; i++) { Debug.Log(pendingObjects[i] + " has not called 'onComplete' yet."); } } }, 2); }
private void Awake() { PersistentLoader.LoadIfNotLoaded(); }