コード例 #1
0
ファイル: SFX_II.cs プロジェクト: kajuanjones/Undead-Arena
    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();
    }
コード例 #3
0
 private void Awake()
 {
     agent      = GetComponent <NavMeshAgent>();
     ts         = GetComponent <TimeScale>();
     soundArray = GetComponent <SoundArray>();
 }