コード例 #1
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         DestroyImmediate(gameObject);
     }
 }
コード例 #2
0
    private void Awake()
    {
        InMenu = true;
        if (_instance != null && _instance != this)
        {
            Destroy(gameObject);
            return;
        }
        else
        {
            _instance = this;
        }
        instance = _instance;

        DontDestroyOnLoad(this);
    }