示例#1
0
 /// <summary>
 /// 播放音频
 /// </summary>
 /// <param name="clipIndex"></param>
 public override void Excute(int clipIndex, Action callback = null)
 {
     if (Clips != null && Clips.Length > 0)
     {
         if (clipIndex >= 0 && clipIndex < Clips.Length)
         {
             MyFuncState = ActionState.DOING;
             if (callback != null)
             {
                 callback     += () => { MyFuncState = ActionState.DONE; };
                 myAudioSource = AudioUtility.Play(gameObject, Clips[clipIndex], callback);
             }
             else
             {
                 myAudioSource = AudioUtility.Play(gameObject, Clips[clipIndex], () => { MyFuncState = ActionState.DONE; });
             }
         }
         else
         {
             Debug.Log("警告:音频下标越界...");
         }
     }
     else
     {
         Debug.Log("警告:Clips没有赋值...");
     }
 }
示例#2
0
 /// <summary>
 /// 重复播放
 /// </summary>
 /// <param name="clipIndex"></param>
 public override void RepeatPlay(int clipIndex)
 {
     if (Clips != null && Clips.Length > 0)
     {
         if (clipIndex >= 0 && clipIndex < Clips.Length)
         {
             MyFuncState   = ActionState.DOING;
             myAudioSource = AudioUtility.Play(gameObject, Clips[clipIndex], true);
         }
         else
         {
             Debug.Log("警告:音频下标越界...");
         }
     }
     else
     {
         Debug.Log("警告:Clips没有赋值...");
     }
 }