コード例 #1
0
ファイル: AudioPlayer.cs プロジェクト: omireault/mk_personal
    public static void PlayClip(AudioClipEnum clipEnum, float delay = 0, float volume = 1)
    {
        int index = (int)clipEnum;

        if (index < 0 || index >= thePlayer.EnumeratedClips.Length)
        {
            Debug.LogError("Count out of range: " + clipEnum.ToString());
            return;
        }
        AudioClip clip = thePlayer.EnumeratedClips[index];

        if (clip == null)
        {
            Debug.LogError("Clip not found: " + clipEnum.ToString());
            return;
        }
        if (delay > 0)
        {
            thePlayer.ExecuteLater(delay, () =>
            {
                thePlayer._mySource.PlayOneShot(clip, volume);
            });
        }
        else
        {
            thePlayer._mySource.PlayOneShot(clip, volume);
        }
    }
コード例 #2
0
ファイル: AudioPlayer.cs プロジェクト: omireault/mk_personal
    public static float ClipLength(AudioClipEnum clipEnum)
    {
        AudioClip clip = thePlayer.EnumeratedClips[(int)clipEnum];

        if (clip == null)
        {
            Debug.LogError("Clip not found: " + clipEnum.ToString());
            return(0);
        }
        return(clip.length);
    }
コード例 #3
0
 //加载声音剪辑
 private AudioClip LoadAudioClip(AudioClipEnum path)
 {
     for (int i = 0; i < audioClipResource.audioClipResource.Count; i++)
     {
         if (audioClipResource.audioClipResource[i].name == path.ToString())
         {
             return(audioClipResource.audioClipResource[i]);
         }
     }
     return(null);
 }
コード例 #4
0
ファイル: AudioPlayer.cs プロジェクト: omireault/mk_personal
    public static void RepeatClip(AudioClipEnum clipEnum, int times, float delay = 0)
    {
        int index = (int)clipEnum;

        if (index < 0 || index >= thePlayer.EnumeratedClips.Length)
        {
            Debug.LogError("Count out of range: " + clipEnum.ToString());
            return;
        }
        AudioClip clip = thePlayer.EnumeratedClips[index];

        if (clip == null)
        {
            Debug.LogError("Clip not found: " + clipEnum.ToString());
            return;
        }
        thePlayer._mySource.clip = clip;
        for (int i = 0; i < times; ++i)
        {
            thePlayer.ExecuteLater(delay + clip.length * i, () => thePlayer._mySource.Play());
        }
    }