コード例 #1
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
コード例 #2
0
    // Use this for initialization
    void Awake()
    {
        if (instance != null && instance != this) {
            Destroy(this.gameObject);
            return;
        }else {
            instance = this;
        }

        if (Application.loadedLevel == 0 || Application.loadedLevel == 2 || Application.loadedLevel == 3)
        {
            DontDestroyOnLoad(this.gameObject);
        }
        else
        {
            Destroy(this.gameObject);
        }
    }
コード例 #3
0
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
            return;
        }
        else
        {
            instance = this;
        }

        if (!AudioBegin)
        {
            music.Play();
            DontDestroyOnLoad(this.gameObject);
            AudioBegin = true;
        }
    }