Пример #1
0
 /// <summary>
 /// Deinitialization
 /// </summary>
 private void OnDestroy()
 {
     // Unset the local instance
     if (Instance == this)
     {
         Instance = null;
     }
 }
Пример #2
0
    /// <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;
    }