public static SoundEffect PlaySoundEffect(string name) { AudioControl audio = AudioControl.sharedControl; if (audio.sfxVolume == 0) return null; AudioClip fx = null; foreach(AudioClip a in audio.effects) { if(a.name == name) { fx = a; break; } } if(fx) { SoundEffect sound = new GameObject().AddComponent<SoundEffect>(); sound.transform.parent = audio.transform; sound.InitEffect(fx); return sound; } else Debug.Log ("Sound effect '" + name + "' not found"); return null; }