예제 #1
0
    void Awake()
    {
        if (instance != null && instance != this)
        {
            if (instance.GetComponent <AudioSource>().clip != gameObject.GetComponent <AudioSource>().clip)
            {
                instance.GetComponent <AudioSource>().clip   = gameObject.GetComponent <AudioSource>().clip;
                instance.GetComponent <AudioSource>().volume = gameObject.GetComponent <AudioSource>().volume;
                instance.GetComponent <AudioSource>().Play();
            }

            Destroy(this.gameObject);
            return;
        }
        instance = this;
        gameObject.GetComponent <AudioSource>().Play();
        DontDestroyOnLoad(this.gameObject);
    }
예제 #2
0
 public void BgmStop()
 {
     if (Instance == null)
     {
         bgm = gameObject.GetComponent <AudioSource>();
     }
     else
     {
         bgm = Instance.GetComponent <AudioSource>();
     }
     if (bgmcheck)
     {
         bgm.enabled = false;
         bgmcheck    = false;
     }
     else
     {
         bgm.enabled = true;
         bgmcheck    = true;
     }
 }
예제 #3
0
 static public void Play()
 {
     instance.GetComponent <AudioSource>().Play();
 }