예제 #1
0
    private void Awake()
    {
        manager = GameObject.Find("ManagerObj").GetComponent <SingletonAudio>();

        inspirationState = new InspirationState(this);
        composingState   = new ComposingState(this);
        stopState        = new StopState(this);
    }
예제 #2
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
예제 #3
0
    void Awake()
    {
        if (_instance == null)
        {
            //make the first instance a singleton
            _instance = this;
            DontDestroyOnLoad(this);
        }

        else
        {
            //if singleton already exists find reference and destroy
            if (this != _instance)
            {
                Destroy(this.gameObject);
            }
        }
    }
예제 #4
0
    void Awake()
    {
        if (instance != null && instance != this)
        {
            if (instance.GetComponent <AudioSource>().clip != GetComponent <AudioSource>().clip)
            {
                instance.GetComponent <AudioSource>().clip   = GetComponent <AudioSource>().clip;
                instance.GetComponent <AudioSource>().volume = GetComponent <AudioSource>().volume;
                instance.GetComponent <AudioSource>().Play();
            }

            Destroy(this.gameObject);
            return;
        }
        instance = this;
        GetComponent <AudioSource>().Play();
        DontDestroyOnLoad(this.gameObject);
    }