Esempio n. 1
0
    // ######################################################################
    // MonoBehaviour Functions
    // ######################################################################

    #region MonoBehaviour

    // Awake is called when the script instance is being loaded.
    void Awake()
    {
        if (instance == null)
        {
            // Make the current instance as the singleton
            instance = this;

            // Make it persistent
            DontDestroyOnLoad(this);
        }
        else
        {
            // If more than one singleton exists in the scene find the existing reference from the scene and destroy it
            if (this != instance)
            {
                Destroy(this.gameObject);
            }
        }
    }
Esempio n. 2
0
	// ######################################################################
	// MonoBehaviour Functions
	// ######################################################################
	
	#region MonoBehaviour
	
	// Awake is called when the script instance is being loaded.
	void Awake()
	{		
		if(instance == null)
		{
			// Make the current instance as the singleton
			instance = this;

			// Make it persistent  
			DontDestroyOnLoad(this);
		}
		else
		{
			// If more than one singleton exists in the scene find the existing reference from the scene and destroy it
			if(this != instance)
			{
				Destroy(this.gameObject);
			}
		}
	}