Ejemplo n.º 1
0
 public void PlayOne(AudioSourceInterface audioInterface)
 {
     if (fadeInsteadOfStopping)
     {
         if (members.Contains(audioInterface))
         {
             foreach (AudioSourceInterface asi in members)
             {
                 if (audioInterface.gameObject.activeInHierarchy && asi != audioInterface) //hey, don't fade down the one thing we WANT to play.
                 {
                     asi.StartCoroutine(asi.FadeVolumeByFactor(fadeFactor, fadeDuration)); //fade out
                     //fade back in after the length of time of the - hopefully - clip that is playing.
                     asi.StartCoroutine(asi.FadeVolumeByFactor(1, fadeDuration, audioInterface.audioSource.clip.length));
                 }
             }
             audioInterface.ForcePlay();//play this clip at the appropriate time.
         }
     }
     else
     {
         if (members.Contains(audioInterface))
         {
             StopAll();
             audioInterface.ForcePlay();
         }
         else
         {
             Debug.LogWarning("audio source not member of group.", audioInterface);
         }
     }
 }
        void Awake()//Initialization
        {
            audioInterface = GetComponent <AudioSourceInterface>();

            if (GetComponent <Rigidbody>() == null)
            {
                Debug.LogWarning("Play on collisions is set but there is no rigidbody attached to this object. It still might work (?) but is probably not intended.", gameObject);
            }
        }
Ejemplo n.º 3
0
 public void DeregisterMember(AudioSourceInterface audioInterface)
 {
     if (members == null)
     {
         return;
     }
     if (members.Contains(audioInterface))
     {
         members.Remove(audioInterface);
     }
 }
Ejemplo n.º 4
0
 public void RegisterMember(AudioSourceInterface audioInterface)
 {
     if (members == null)
     {
         members = new List <AudioSourceInterface>();
     }
     if (!members.Contains(audioInterface))
     {
         members.Add(audioInterface);
     }
     else
     {
         Debug.LogWarning("Audio Source already member of group: " + this.name, audioInterface);
     }
 }
        void Start()
        {
            audioInterface = GetComponent <AudioSourceInterface>();

            #region Tests
            if (audioInterface.audioSource.playOnAwake)
            {
                Debug.LogWarning("Audio source for play once handler is set to play on awake. This is probably unintentional.");
            }
            #endregion

            //Option clip override.
            if (sourceClip != null)
            {
                audioInterface.SetClip(sourceClip);
            }
        }
 void Awake()
 {
     audioInterface = GetComponent <AudioSourceInterface>();
 }