private void OnDestroy() { // unset the singleton reference if it is the current instance if (_instance == this) { _instance = null; } }
private void Awake() { // check if an object already exists if (_instance != null) { throw new Exception("Only a single instance of 'FirstResponder` should exist at a time."); } _instance = this; }