private void StopSound(GameObject gameObj, string soundName) { if (gameObj != gameObject) { return; } SoundStructure audio = Array.Find(soundList, sound => sound.name == soundName); if (audio == null || audio.source == null) { Debug.LogWarning("Sound : " + soundName + " not found!"); return; } audio.source.Stop(); }
private void PlaySound(GameObject gameObj, string soundName) { if (gameObj != gameObject) { return; } //return element if-- element.name == givenName SoundStructure audio = Array.Find(soundList, sound => sound.name == soundName); if (audio == null || audio.source == null) { Debug.LogWarning("Sound : " + soundName + " not found!"); return; } audio.source.volume = audio.volume; audio.source.pitch = audio.pitch; audio.source.loop = audio.loop; audio.source.spatialBlend = audio.spatialBlend; audio.source.Play(); }