예제 #1
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(this);

            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music_Source_" + "0" + (i + 1));
                musicSources[i] = newMusicSource.AddComponent <AudioSource> ();
                newMusicSource.transform.parent = this.transform;
            }

            library = GetComponent <SFXLibrary> ();
        }
    }
예제 #2
0
 public static void Init()
 {
     AnimationLibray = new AnimationLibrary();
     SFXLibrary      = new SFXLibrary();
 }
예제 #3
0
 public void SetSound(string soundName)
 {
     m_audioSrc.clip = SFXLibrary.GetSound(soundName);
 }
예제 #4
0
 public void PlayOneShot(string soundName, float volume = 1.0f, float pitch = 1.0f)
 {
     m_audioSrc.loop  = false;
     m_audioSrc.pitch = pitch;
     m_audioSrc.PlayOneShot(SFXLibrary.GetSound(soundName), volume);
 }