private void OnDestroy() { if (_mainLoopScanner == this) { _mainLoopScanner = null; } }
private void Awake() { // Severals instances of MainLoopScanner are not allowed. if(_mainLoopScanner != null) { EditorUtility.DisplayDialog("Invalid operation", "Can't add 'MainLoopEditorScanner' to "+gameObject.name+" because a 'MainLoopEditorScanner' is already added to another game object in the scene!", "Ok", ""); DestroyImmediate(this); return; } _mainLoopScanner = this; }