コード例 #1
0
    void Awake()
    {
        indexScene  = SceneManager.GetActiveScene().buildIndex;
        totalScenes = SceneManager.sceneCountInBuildSettings;
        middleScene = ((totalScenes - 2) / 2) + 2;
        Debug.Log("The actual Scene is: " + indexScene);


        if ((indexScene == middleScene || indexScene == 1 || indexScene == 0))
        {
            Destroy(GameObject.Find("BG"));
            instance = null;
        }


        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
        }
    }
コード例 #2
0
 private void Awake()
 {
     if (instance != null && instance != this)
     {
         UnityEngine.Object.Destroy(base.gameObject);
         return;
     }
     instance = this;
     Object.DontDestroyOnLoad(base.gameObject);
 }
コード例 #3
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
コード例 #4
0
 void Start()
 {
     gameObject.GetComponent <AudioSource>().Play();
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
コード例 #5
0
        void Awake()
        {
            if (instance != null && instance != this)
            {
                Destroy(this.gameObject);
                return;
            }
            else
            {
                instance = this;
            }

            DontDestroyOnLoad(this.gameObject);

            if ((SceneManager.GetActiveScene().buildIndex == 7))
            {
                Destroy(gameObject);
            }
        }
コード例 #6
0
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
        }
        Scene scene = SceneManager.GetActiveScene();

        if (scene.name == "Main Menu")
        {
            DontDestroyOnLoad(this.gameObject);
            setNotDestroyed = true;
        }
    }
コード例 #7
0
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
        }
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }

        /*  if (instance != null && instance != this)
         * {
         *    Destroy(this.gameObject);
         *    return;
         * }
         * else
         * {
         *    instance = this;
         * }
         *
         * DontDestroyOnLoad(this.gameObject);*/
    }