//Sound Effect
 public void PlaySFX(AudioClipID audioClipID)
 {
     if (!sfxAudioSource.isPlaying)
     {
         sfxAudioSource.PlayOneShot(FindAudioClip(audioClipID), sfxVolume);
     }
 }
예제 #2
0
 //! BACKGROUND MUSIC (BGM)
 public void PlayBGM(AudioClipID audioClipID)
 {
     bgmAudioSource.clip = FindAudioClip(audioClipID);
     Debug.Log(audioClipID);
     bgmAudioSource.volume = bgmVolume;
     bgmAudioSource.Play();
 }
예제 #3
0
    public void PlayLoopingSFXWithFadeIn(AudioClipID audioClipID, float fadeInDuration)
    {
        AudioClip clipToPlay = FindAudioClip(audioClipID);

        if (clipToPlay == null)
        {
            return;
        }

        for (int i = 0; i < loopingSFXAudioSourceList.Count; i++)
        {
            if (loopingSFXAudioSourceList[i].clip == clipToPlay)
            {
                if (loopingSFXAudioSourceList[i].isPlaying)
                {
                    return;
                }

                loopingSFXAudioSourceList[i].volume = sfxVolume;
                StartCoroutine(FadeIn(loopingSFXAudioSourceList[i], clipToPlay, fadeInDuration, sfxVolume));
                return;
            }
        }

        AudioSource newInstance = sfxAudioSource.gameObject.AddComponent <AudioSource>();

        newInstance.playOnAwake = false;
        newInstance.loop        = true;

        StartCoroutine(FadeIn(newInstance, clipToPlay, fadeInDuration, sfxVolume));
        loopingSFXAudioSourceList.Add(newInstance);
    }
예제 #4
0
    public void PlayLoopingSFX(AudioClipID audioClipID)
    {
        AudioClip clipToPlay = FindAudioClip(audioClipID);

        if (clipToPlay == null)
        {
            return;
        }

        for (int i = 0; i < loopingSFXAudioSourceList.Count; i++)
        {
            if (loopingSFXAudioSourceList[i].clip == clipToPlay)
            {
                if (loopingSFXAudioSourceList[i].isPlaying)
                {
                    return;
                }

                loopingSFXAudioSourceList[i].volume = sfxVolume;
                loopingSFXAudioSourceList[i].Play();
                return;
            }
        }

        AudioSource newInstance = sfxAudioSource.gameObject.AddComponent <AudioSource>();

        newInstance.playOnAwake = false;
        newInstance.clip        = clipToPlay;
        newInstance.volume      = sfxVolume;
        newInstance.loop        = true;
        newInstance.Play();
        loopingSFXAudioSourceList.Add(newInstance);
    }
예제 #5
0
    public void PlayLoopingSFX(AudioClipID audioClipID, GameObject go)
    {
        AudioClip clipToPlay = FindAudioClip(audioClipID);

        AudioSource source = FindAudioSource(go);

        if (source == null)
        {
            AudioSource newInstance = go.AddComponent <AudioSource>();
            newInstance.clip         = clipToPlay;
            newInstance.volume       = sfxVolume;
            newInstance.loop         = true;
            newInstance.spatialBlend = 1.0f;             //For 3D sounds
            newInstance.Play();
            sfxAudioSourceList3D.Add(newInstance);
        }
        else
        {
            if (source.clip != clipToPlay)
            {
                source.clip = clipToPlay;
            }

            if (source.isPlaying)
            {
                return;
            }

            source.volume = sfxVolume;
            source.Play();
            return;
        }
    }
    public void PlayLoopingSFX(AudioClipID audioClipID)
    {
        AudioClip clipToPlay = FindAudioClip(audioClipID);

        for (int i = 0; i < sfxAudioSourceList.Count; i++)
        {
            if (sfxAudioSourceList[i].clip == clipToPlay)
            {
                if (sfxAudioSourceList[i].isPlaying)
                {
                    return;
                }

                sfxAudioSourceList[i].volume = sfxVolume;
                sfxAudioSourceList[i].Play();
                return;
            }
        }

        AudioSource newInstance = gameObject.AddComponent <AudioSource>();

        newInstance.clip   = clipToPlay;
        newInstance.volume = sfxVolume;
        newInstance.loop   = true;
        newInstance.Play();
        sfxAudioSourceList.Add(newInstance);
    }
예제 #7
0
 //! BACKGROUND MUSIC (BGM)
 public void PlayBGM(AudioClipID audioClipID)
 {
     bgmAudioSource.clip   = FindAudioClip(audioClipID);
     bgmAudioSource.volume = bgmVolume;
     bgmAudioSource.loop   = true;
     bgmAudioSource.Play();
 }
예제 #8
0
    //! SOUND EFFECTS (SFX)
    public void PlaySFX(AudioClipID audioClipID, GameObject go)
    {
        AudioSource source = FindAudioSource(go);

        if (source != null)
        {
            source.PlayOneShot(FindAudioClip(audioClipID), sfxVolume);
        }
    }
예제 #9
0
 public void FadeInPlayBGM(AudioClipID audioClipID)
 {
     if (!bgmAudioSource.isPlaying)
     {
         bgmAudioSource.clip = FindAudioClip(audioClipID);
         bgmAudioSource.loop = true;
         StartCoroutine(FadeIn(bgmAudioSource, bgmAudioSource.clip, 0.5f, 1f));
     }
 }
 AudioClip FindAudioClip(AudioClipID audioClipID)
 {
     for (int i = 0; i < audioClipInfoList.Count; i++)
     {
         if (audioClipInfoList [i].audioClipID == audioClipID)
         {
             return(audioClipInfoList [i].audioCLip);
         }
     }
     return(null);
 }
예제 #11
0
    AudioClip FindAudioClip(AudioClipID audioID)
    {
        for (int i = 0; i < audioClipList.Count; i++)
        {
            if (audioClipList[i].audioID == audioID)
            {
                return(audioClipList[i].audioClip);
            }
        }

        Debug.Log("Cannot find audioClip : " + audioID);
        return(null);
    }
    public void ChangePitchLoopingSFX(AudioClipID audioClipID, float value)
    {
        AudioClip clipToStop = FindAudioClip(audioClipID);

        for (int i = 0; i < sfxAudioSourceList.Count; i++)
        {
            if (sfxAudioSourceList[i].clip == clipToStop)
            {
                sfxAudioSourceList[i].pitch = value;
                return;
            }
        }
    }
예제 #13
0
    public void PlayBGMWithFadeIn(AudioClipID audioClipID, float fadeInDuration)
    {
        AudioClip clipToPlay = FindAudioClip(audioClipID);

        if (clipToPlay == null)
        {
            return;
        }

        bgmAudioSource.loop = true;

        StartCoroutine(FadeIn(bgmAudioSource, clipToPlay, fadeInDuration, bgmVolume));
    }
    public void StopLoopingSFX(AudioClipID audioClipID)
    {
        AudioClip clipToStop = FindAudioClip(audioClipID);

        for (int i = 0; i < sfxAudioSourceList.Count; i++)
        {
            if (sfxAudioSourceList[i].clip == clipToStop)
            {
                sfxAudioSourceList[i].Stop();
                return;
            }
        }
    }
    public void PauseLoopingSFX(AudioClipID audioClipID)
    {
        AudioClip clipToPause = FindAudioClip(audioClipID);

        for (int i = 0; i < sfxAudioSourceList.Count; i++)
        {
            if (sfxAudioSourceList[i].clip == clipToPause)
            {
                sfxAudioSourceList[i].Pause();
                return;
            }
        }
    }
    public AudioClip FindSFXClip(AudioClipID audioClipID)
    {
        for (int i = 0; i < audioClipInfo.Count; i++)
        {
            if (audioClipInfo[i].audioClipID == audioClipID)
            {
                return(audioClipInfo[i].audioClip);
            }
        }

        Debug.LogError("Cannot find ID: " + audioClipID);

        return(null);
    }
예제 #17
0
    //! BACKGROUND MUSIC (BGM)
    public void PlayBGM(AudioClipID audioClipID)
    {
        AudioClip clipToPlay = FindAudioClip(audioClipID);

        if (clipToPlay == null)
        {
            return;
        }

        bgmAudioSource.clip   = clipToPlay;
        bgmAudioSource.volume = bgmVolume;
        bgmAudioSource.loop   = true;
        bgmAudioSource.Play();
    }
    public AudioClip FindAudioClip(AudioClipID audioClipID)
    {
        for (int i = 0; i < audioClipInfoList.Count; i++)
        {
            if (audioClipInfoList[i].audioClipID == audioClipID)
            {
                return(audioClipInfoList[i].audioClip);
            }
        }

        Debug.LogError("Cannot Find Audio Clip : " + audioClipID);

        return(null);
    }
예제 #19
0
        public void PlaySFX(AudioClipID audioClipID)
        {
            AudioClipInfo clipToPlay = FindAudioClip(audioClipID);

            if (clipToPlay == null)
            {
                return;
            }

            AudioSource player = FindReadyAudioSource(clipToPlay);

            if (player != null)
            {
                player.PlayOneShot(clipToPlay.audioClip, sfxVolume);
            }
        }
예제 #20
0
    public void StopLoopingSFX(AudioClipID audioClipID, GameObject go)
    {
        AudioClip clipToStop = FindAudioClip(audioClipID);

        AudioSource source = FindAudioSource(go);

        if (source == null)
        {
            return;
        }

        if (source.clip == clipToStop)
        {
            source.Stop();
        }
    }
예제 #21
0
    public void PauseLoopingSFX(AudioClipID audioClipID, GameObject go)
    {
        AudioClip clipToPause = FindAudioClip(audioClipID);

        AudioSource source = FindAudioSource(go);

        if (source == null)
        {
            return;
        }

        if (source.clip == clipToPause)
        {
            source.Pause();
        }
    }
예제 #22
0
    public void ChangePitchLoopingSFX(AudioClipID audioClipID, float value, GameObject go)
    {
        AudioClip clipToChange = FindAudioClip(audioClipID);

        AudioSource source = FindAudioSource(go);

        if (source == null)
        {
            return;
        }

        if (source.clip == clipToChange)
        {
            source.pitch = value;
        }
    }
예제 #23
0
        public void PlayBGMWithFadeOutIn(AudioClipID audioClipID, float fadeOutDuration, float fadeInDuration)
        {
            AudioClipInfo clipToPlay = FindAudioClip(audioClipID);

            if (clipToPlay == null)
            {
                return;
            }

            AudioSource player = FindReadyAudioSource(clipToPlay);

            if (player != null)
            {
                player.loop = true;
                StartCoroutine(FadeOutIn(player, fadeOutDuration, fadeInDuration, bgmVolume));
            }
        }
예제 #24
0
    public void StopLoopingSFX(AudioClipID audioClipID)
    {
        AudioClip clipToStop = FindAudioClip(audioClipID);

        if (clipToStop == null)
        {
            return;
        }

        for (int i = 0; i < loopingSFXAudioSourceList.Count; i++)
        {
            if (loopingSFXAudioSourceList[i].clip == clipToStop)
            {
                loopingSFXAudioSourceList[i].Stop();
                return;
            }
        }
    }
예제 #25
0
    public void PauseLoopingSFX(AudioClipID audioClipID)
    {
        AudioClip clipToPause = FindAudioClip(audioClipID);

        if (clipToPause == null)
        {
            return;
        }

        for (int i = 0; i < loopingSFXAudioSourceList.Count; i++)
        {
            if (loopingSFXAudioSourceList[i].clip == clipToPause)
            {
                loopingSFXAudioSourceList[i].Pause();
                return;
            }
        }
    }
예제 #26
0
        public void PlayBGM(AudioClipID audioClipID)
        {
            AudioClipInfo clipToPlay = FindAudioClip(audioClipID);

            if (clipToPlay == null)
            {
                return;
            }

            AudioSource player = FindReadyAudioSource(clipToPlay);

            if (player != null)
            {
                player.volume = bgmVolume;
                player.loop   = true;
                player.Play();
            }
        }
    public void FadeInPlayBGM(AudioClipID audioClipID)
    {
        if (!bgmAudioSource.isPlaying)
        {
            bgmAudioSource.clip = FindAudioClip(audioClipID);
            StopCoroutine("FadeInBGMRoutine");
            StartCoroutine("FadeInBGMRoutine");
            Debug.Log(bgmVolume);
            bgmAudioSource.loop = true;
            bgmAudioSource.Play();
        }

        /*if(!bgmAudioSource.isPlaying)
         * {
         *      bgmAudioSource.clip = FindAudioClip(audioClipID);
         *      StartCoroutine(FadeIn(bgmAudioSource, bgmAudioSource.clip, 0.5f, 1f));
         * }
         */
    }
    public void PlayBGM(AudioClipID audioClipID)
    {
        /*if(!bgmAudioSource.isPlaying)
         * {
         *      bgmAudioSource.clip = FindAudioClip(audioClipID);
         *      bgmAudioSource.volume = bgmVolume;
         *      bgmAudioSource.loop = true;
         *      bgmAudioSource.Play();
         * }*/

        //Baz Version
        AudioClip clipToPlay = FindAudioClip(audioClipID);

        if (clipToPlay == null)
        {
            return;
        }

        bgmAudioSource.clip   = clipToPlay;
        bgmAudioSource.volume = bgmVolume;
        bgmAudioSource.loop   = true;
        bgmAudioSource.Play();
    }
예제 #29
0
 // SFX Functions
 public void PlaySFX(AudioClipID sfxAudioID)
 {
     sfxAudioSource.volume = bgmVolume;
     sfxAudioSource.PlayOneShot(FindAudioClip(sfxAudioID), sfxVolume);
 }
 //! SOUND EFFECTS (SFX)
 public void PlaySFX(AudioClipID audioClipID)
 {
     sfxAudioSource.PlayOneShot(FindAudioClip(audioClipID), sfxVolume / 2.5f);
 }