// ------------------------------------------------------------------------------- // PlaySound // ------------------------------------------------------------------------------- private static SoundObject PlaySound(SoundTemplate tmpl) { if (tmpl == null) { return(null); } SoundObject sound = ((GameObject)GameObject.Instantiate(tmpl.soundObjectPrefab)).GetComponent <SoundObject>(); sound.SetClip(tmpl); return(sound); }
// ------------------------------------------------------------------------------- // Play // ------------------------------------------------------------------------------- public static SoundObject Play(SoundTemplate tmpl, Vector3 pos) { SoundObject sound = PlaySound(tmpl); if (sound == null) { return(null); } sound.transform.position = pos; return(sound); }
// ------------------------------------------------------------------------------- // SetClip // ------------------------------------------------------------------------------- public void SetClip(SoundTemplate sound) { if (source == null) { source = GetComponent <AudioSource>(); } source.clip = sound.clip; source.volume = sound.volume * SoundController.GetVolume(); source.spatialBlend = sound.is2d ? 0 : 1; source.Play(); Destroy(this.gameObject, sound.clip.length + 0.5f); }
// ------------------------------------------------------------------------------- // Play // ------------------------------------------------------------------------------- public static SoundObject Play(SoundTemplate tmpl, Transform tran) { SoundObject sound = PlaySound(tmpl); if (sound == null) { return(null); } sound.transform.parent = tran; sound.transform.localPosition = Vector3.zero; return(sound); }
// ------------------------------------------------------------------------------- // Play // ------------------------------------------------------------------------------- public static SoundObject Play(SoundTemplate tmpl) { SoundObject sound = PlaySound(tmpl); return(sound); }