private void UF_UpdatePlayClipEvent() { if (m_CurrentPlayClip != null) { m_PlayingTime += GTime.RunDeltaTime; float progress = m_PlayingLength <= 0 ? 1:Mathf.Clamp01(m_PlayingTime / m_PlayingLength); progress = GHelper.ShortFloat(progress); if (m_CurrentPlayClip.playingAcitveEvent) { var count = m_CurrentPlayClip.clipEvents.Count; for (int k = m_EventTriggerIndex; k < count; k++) { if (progress >= m_CurrentPlayClip.clipEvents [k].trigger) { m_EventTriggerIndex++; UF_ExcuteAnimatorClipEvent(m_CurrentPlayClip.name, m_CurrentPlayClip.playingParam, m_CurrentPlayClip.clipEvents [k].name, m_CurrentPlayClip.clipEvents [k].param); } } } if (progress >= 1) { m_PlayingTime = m_PlayingLength; m_isPlayingElemelt = false; GHelper.UF_SafeCallDelegate(m_CurrentPlayClip.playingCallback, null); } } }
private void UF_PlayAnimatorClip(AnimatorClip aClip) { //获取影片播放长度 m_PlayingLength = UF_GetAnimationClipRealLength(m_CurrentPlayClip.name) / m_CurrentPlayClip.playingSpeed; m_PlayingLength = GHelper.ShortFloat(m_PlayingLength); //设置当前影片播放速度 this.speed = m_CurrentPlayClip.speed * m_CurrentPlayClip.playingSpeed; //重置索引 m_EventTriggerIndex = 0; //重置当前影片播放时间 m_PlayingTime = 0; m_IsOver = false; m_isPlayingElemelt = true; //播放影片动画 if (m_Animator == null) { Debugger.UF_Warn("Animator Component is null,Animation will not play!"); return; } switch (aClip.crossMode) { case AnimatorClip.CrossMode.CrossFabe: m_Animator.CrossFadeInFixedTime(aClip.clipName, aClip.fadeFactor); break; case AnimatorClip.CrossMode.Direct: if (aClip.wrapMode == WrapMode.Loop) { m_Animator.Play(aClip.clipName); } else { m_Animator.Play(aClip.clipName, 0, 0); } break; default: m_Animator.Play(aClip.clipName); break; } }