123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- using UnityEngine;
- using System.Collections;
- namespace OVR
- {
- /*
- -----------------------
- SoundFXRef
- just a references to a SoundFX.. all the SoundFX methods are called indirectly from here
- -----------------------
- */
- [System.Serializable]
- public class SoundFXRef {
- public string soundFXName = string.Empty;
- private bool initialized = false;
- private SoundFX soundFXCached = null;
- public SoundFX soundFX {
- get {
- if ( !initialized ) {
- Init();
- }
- return soundFXCached;
- }
- }
- public string name { get { return soundFXName; } set { soundFXName = value; Init(); } }
- /*
- -----------------------
- Init()
- -----------------------
- */
- void Init() {
- // look up the actual SoundFX object
- soundFXCached = AudioManager.FindSoundFX( soundFXName );
- if ( soundFXCached == null ) {
- soundFXCached = AudioManager.FindSoundFX( string.Empty );
- }
- initialized = true;
- }
- /*
- -----------------------
- Length()
- -----------------------
- */
- public int Length { get { return soundFX.Length; } }
- /*
- -----------------------
- IsValid()
- -----------------------
- */
- public bool IsValid { get { return soundFX.IsValid; } }
- /*
- -----------------------
- GetClip()
- -----------------------
- */
- public AudioClip GetClip() {
- return soundFX.GetClip();
- }
- /*
- -----------------------
- GetClipLength()
- -----------------------
- */
- public float GetClipLength( int idx ) {
- return soundFX.GetClipLength( idx );
- }
- /*
- -----------------------
- PlaySound()
- -----------------------
- */
- public int PlaySound( float delaySecs = 0.0f ) {
- return soundFX.PlaySound( delaySecs );
- }
-
- /*
- -----------------------
- PlaySoundAt()
- -----------------------
- */
- public int PlaySoundAt( Vector3 pos, float delaySecs = 0.0f, float volume = 1.0f, float pitchMultiplier = 1.0f ) {
- return soundFX.PlaySoundAt( pos, delaySecs, volume, pitchMultiplier );
- }
- /*
- -----------------------
- SetOnFinished()
- get a callback when the sound is finished playing
- -----------------------
- */
- public void SetOnFinished( System.Action onFinished ) {
- soundFX.SetOnFinished( onFinished );
- }
- /*
- -----------------------
- SetOnFinished()
- get a callback with an object parameter when the sound is finished playing
- -----------------------
- */
- public void SetOnFinished( System.Action<object> onFinished, object obj ) {
- soundFX.SetOnFinished( onFinished, obj );
- }
- /*
- -----------------------
- StopSound()
- -----------------------
- */
- public bool StopSound() {
- return soundFX.StopSound();
- }
- /*
- -----------------------
- AttachToParent()
- -----------------------
- */
- public void AttachToParent( Transform parent)
- {
- soundFX.AttachToParent( parent);
- }
- /*
- -----------------------
- DetachFromParent()
- -----------------------
- */
- public void DetachFromParent()
- {
- soundFX.DetachFromParent();
- }
- }
- } // namespace OVR
|