public void PlayUISound(int anIndexNumber, Vector3 aPosition, float spacialBlend) { if (uiObjectList == null) { return; } // make sure we're not trying to play a sound indexed higher than exists in the array if (anIndexNumber > uiObjectList.Count) { anIndexNumber = uiObjectList.Count - 1; } tempSoundObj = (SoundObject)uiObjectList[anIndexNumber]; tempSoundObj.source.spatialBlend = spacialBlend; tempSoundObj.PlaySound(aPosition); }
void Start() { gameplayObjectList = new ArrayList(); uiObjectList = new ArrayList(); // make sound objects for all of the sounds in (Gameplay)GameSounds array foreach (AudioClip theSound in GameplaySounds) { tempSoundObj = new SoundObject(theSound, theSound.name, volume); gameplayObjectList.Add(tempSoundObj); totalSounds++; } foreach (AudioClip theSound in UISounds) { tempSoundObj = new SoundObject(theSound, theSound.name, volume); uiObjectList.Add(tempSoundObj); totalSounds++; } }