예제 #1
0
 void Awake()
 {
     if( instance != null && instance != this ) {
         Destroy (this.gameObject);
         return;
     } else {
         instance = this;
     }
     DontDestroyOnLoad(gameObject);
 }
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
 }
예제 #3
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(gameObject);
 }
예제 #4
0
    void Awake()
    {
        if (_instance == null)
        {
            //If I am the first instance, make me the Singleton
            _instance = this;
            DontDestroyOnLoad(this);
        }
        else
        {
            //If a Singleton already exists and you find
            //another reference in scene, destroy it!
            if (this != _instance)
            {
                Destroy(this.gameObject);
            }
        }
        AudioSource menuMusic = GetComponent <AudioSource>();

        print(menuMusic.ToString());
        menuMusic.Play();
    }