/// <summary> /// Deinitialization /// </summary> private void OnDestroy() { // Unset the local instance if (Instance == this) { Instance = null; } }
/// <summary> /// Resource Initialization /// </summary> private void Awake() { // Check if this is the only instance if (Instance != null) { // This is a secondary instance, delete it Destroy(gameObject); return; } // Set instance Instance = this; }