private void Awake() { if (_instance != null) { Debug.LogError("Tried to create another UnityWrapper instance! Destroying the new instance with extreme prejudice..."); GameObject.Destroy(this.gameObject); return; } _instance = this; // this singleton persists for the lifetime of the application DontDestroyOnLoad(gameObject); }
/// <summary> /// Call this to destroy all modules and invalidate this entity. /// </summary> public void Destroy() { UnityWrapper.Unregister(this); DestroyInternal(); _myEntity = null; }
protected UnityBehaviour() { UnityWrapper.Register(this); }