예제 #1
0
    public void PopulateLists()
    {
        soundArrays.Clear();

        int children = transform.childCount;

        for (int i = 0; i < children; i++)
        {
            Transform  child      = transform.GetChild(i);
            SoundArray soundArray = new SoundArray(child.name);

            foreach (AudioSource source in child.GetComponents <AudioSource>())
            {
                source.playOnAwake           = false;
                source.outputAudioMixerGroup = mixer.FindMatchingGroups("Sfx")[0];
                soundArray.sources.Add(source);
            }

            soundArrays.Add(soundArray);
        }

        foreach (SoundArray soundArray in soundArrays)
        {
            //Debug.Log(soundArray.name + " contains ");

            foreach (AudioSource source in soundArray.sources)
            {
                //Debug.Log(source.name);
            }
        }
    }
예제 #2
0
    public void Play(string name)
    {
        SoundArray s = Array.Find(sounds, sound => sound.name == name);

        if (s == null)
        {
            Debug.LogWarning("Sound: " + name + " not found!");
            return;
        }
        s.source.Play();
    }
 private void Awake()
 {
     agent      = GetComponent <NavMeshAgent>();
     ts         = GetComponent <TimeScale>();
     soundArray = GetComponent <SoundArray>();
 }