private void OnDestroy() { if (m_TargetActionTween != null) { m_TargetActionTween.Kill(); } m_TargetActionTween = null; }
private ActionTween CreateActionTween(ActionTweenType tweenType) { ActionTween resultAction = null; switch (tweenType) { case ActionTweenType.None: break; case ActionTweenType.Move: if (m_MoveToType == MoveAction.MoveToType.Target) { resultAction = transform.MoveTween(m_MoveTargetTransform, m_Duration); } else if (m_MoveToType == MoveAction.MoveToType.Pos) { resultAction = transform.MoveTween(m_MoveTargetPos, m_Duration); } break; case ActionTweenType.Rotation: if (m_RotToType == RotationAction.RotToType.Target) { resultAction = transform.RotationTween(m_RotToTarget, m_Duration, m_RotModel); } else if (m_RotToType == RotationAction.RotToType.Value) { resultAction = transform.RotationTween(m_RotToVec, m_Duration, m_RotModel); } break; case ActionTweenType.Scale: resultAction = transform.ScaleTween(m_ScaleTarget, m_Duration); break; case ActionTweenType.Color: resultAction = transform.ColorTween(m_TarCol, m_Duration, m_ColorType); break; case ActionTweenType.Fade: resultAction = transform.FadeTween(m_FadeTarAlpha, m_Duration, m_FadeType); break; default: break; } return(resultAction); }
/// <summary> /// 计算Tween的总共持续时间 /// </summary> /// <param name="tween"></param> /// <returns></returns> private float CalFullTimeOfTween(ActionTween tween) { float durationTime = tween.GetCalDurationTime(); if (tween.mActionType == ActionEnum.ActionType.Loop || tween.mActionType == ActionEnum.ActionType.Pingpang) { if (tween.mLoopTime == -1 || tween.mLoopTime == 0) { return(durationTime); } else { return(durationTime * tween.mLoopTime); } } return(durationTime); }
/// <summary> /// 添加动画Tween到序列指定时间点beginTimePos /// </summary> /// <param name="beginTimePos">时间点</param> /// <param name="tween">添加的动画</param> /// <returns></returns> public SequenceAction Add(float beginTimePos, ActionTween tween) { tween.mAutoKill = false; tween.mAutoPlay = false; ActionTweenManager.Instance.Remove(tween); SequenceTweenProperty stp; stp.m_IsPlay = false; stp.m_ActionTween = tween; stp.m_BeginTime = beginTimePos; stp.m_EndTime = beginTimePos + CalFullTimeOfTween(tween); //stp.m_BeginPercent = beginTimePos / mDuration; m_SequenceTweens.Add(stp); if (m_DurationFullTime < stp.m_EndTime) { m_DurationFullTime = stp.m_EndTime; } return(this); }
/// <summary> /// 设置此动画的时间缩放 /// </summary> /// <param name="tween"></param> /// <param name="scaleTime"></param> /// <returns></returns> public static ActionTween SetActionScaleTime(this ActionTween tween, float scaleTime) { tween.mScaleTime = scaleTime; return(tween); }
/// <summary> /// 设置运动方向 /// </summary> /// <param name="tween"></param> /// <param name="direction"></param> /// <returns></returns> public static ActionTween SetActionDirectionType(this ActionTween tween, ActionEnum.ActionDirectionType direction) { tween.mActionDirectionType = direction; return(tween); }
/// <summary> /// 添加动作进入缓存 /// </summary> /// <param name="actionTween"></param> public void Add(ActionTween actionTween) { mWillAddTweens.Add(actionTween); }
/// <summary> /// 每帧更新的时候调用,尽量不要在这个函数内调用过度消耗性能的方法 /// </summary> /// <param name="tween"></param> /// <param name="callback"></param> /// <returns></returns> public static ActionTween SetStepUpdateCallback(this ActionTween tween, ActionTweenCallback callback) { tween.mOnStepUpdate = callback; return(tween); }
/// <summary> /// 动画开始的时候回调函数 /// </summary> /// <param name="tween"></param> /// <param name="callback"></param> /// <returns></returns> public static ActionTween SetBeginPlayCallback(this ActionTween tween, ActionTweenCallback callback) { tween.mOnBeginPlay = callback; return(tween); }
/// <summary> /// 是否采用相对关系 /// </summary> /// <param name="tween"></param> /// <param name="isRelative"></param> /// <returns></returns> public static ActionTween SetRelative(this ActionTween tween, bool isRelative) { tween.mRelative = isRelative; return(tween); }
/// <summary> /// 是否启动速度来运行动画 /// </summary> /// <param name="tween"></param> /// <param name="useSpeed"></param> /// <returns></returns> public static ActionTween SetSpeedAble(this ActionTween tween, bool useSpeed) { tween.mUseSpeed = useSpeed; return(tween); }
private void InitActionTween(ActionTween at) { if (at != null) { at.SetEase(m_EaseEnum) .SetActionDirectionType(m_ActionDirection) .SetActionScaleTime(m_ScaleTime) .SetActionType(m_ActionType) .SetAnimCurve(m_ActionCurve) .SetLoopTime(m_LoopTime) .SetSpeed(m_Speed) .SetSpeedAble(m_UseSpeed) .SetRelative(m_Relative) .SetAutoPlay(m_AutoPlay) .SetAutoKill(m_AutoKill); // Init BeginPlay Event if (m_EnableBeginAction) { at.SetBeginPlayCallback(() => { if (OnBeginPlayEvent != null) { OnBeginPlayEvent.Invoke(); } }); } // Init Complete Event if (m_EnableCompleteAction) { at.SetCompleteCallback(() => { if (OnCompleteEvent != null) { OnCompleteEvent.Invoke(); } }); } // Init Kill Event if (m_EnableKillAction) { at.SetKillCallback(() => { if (OnKillEvent != null) { OnKillEvent.Invoke(); } }); } // Init LoppComplete Event if (m_EnableLoopCompleteAction) { at.SetLoopCompleteCallback(() => { if (OnLoopCompleteEvent != null) { OnLoopCompleteEvent.Invoke(); } }); } // Init LoppComplete Event if (m_EnableStepUpdateAction) { at.SetStepUpdateCallback(() => { if (OnStepUpdateEvent != null) { OnStepUpdateEvent.Invoke(); } }); } } }
private void Awake() { m_TargetActionTween = CreateActionTween(m_AnimationType); InitActionTween(m_TargetActionTween); }
/// <summary> /// 删除缓存里的动作 /// </summary> /// <param name="actionTween"></param> public void Remove(ActionTween actionTween) { mWillRemoveTweens.Add(actionTween); }
/// <summary> /// 设置循环次数 /// </summary> /// <param name="tween"></param> /// <param name="loopTime"></param> /// <returns></returns> public static ActionTween SetLoopTime(this ActionTween tween, int loopTime) { tween.mLoopTime = loopTime; return(tween); }
/// <summary> /// 设置动画类型 /// </summary> /// <param name="tween"></param> /// <param name="actionType"></param> /// <returns></returns> public static ActionTween SetActionType(this ActionTween tween, ActionEnum.ActionType actionType) { tween.mActionType = actionType; return(tween); }
/// <summary> /// 添加动画在序列末尾 /// </summary> /// <param name="tween"></param> /// <returns></returns> public SequenceAction Append(ActionTween tween) { return(Add(m_DurationFullTime, tween)); }
/// <summary> /// 设置速度 /// </summary> /// <param name="tween"></param> /// <param name="speed"></param> /// <returns></returns> public static ActionTween SetSpeed(this ActionTween tween, float speed) { tween.mSpeed = speed; return(tween); }
/// <summary> /// 设置缓冲动作 /// </summary> /// <param name="tween"></param> /// <param name="ease"></param> /// <returns></returns> public static ActionTween SetEase(this ActionTween tween, EaseEnum ease) { tween.mEaseEnum = ease; return(tween); }
/// <summary> /// 设置是否自动播放 /// </summary> /// <param name="tween"></param> /// <param name="autoPlay"></param> /// <returns></returns> public static ActionTween SetAutoPlay(this ActionTween tween, bool autoPlay) { tween.ActionActive = autoPlay; tween.mAutoPlay = autoPlay; return(tween); }
/// <summary> /// 设置动画曲线 /// </summary> /// <param name="tween"></param> /// <param name="curve"></param> /// <returns></returns> public static ActionTween SetAnimCurve(this ActionTween tween, AnimationCurve curve) { tween.mActionCurve = curve; return(tween); }
/// <summary> /// 动画被杀死时回调 /// </summary> /// <param name="tween"></param> /// <param name="callback"></param> /// <returns></returns> public static ActionTween SetKillCallback(this ActionTween tween, ActionTweenCallback callback) { tween.mOnKill = callback; return(tween); }
/// <summary> /// 设置自动Kill /// </summary> /// <param name="tween"></param> /// <returns></returns> public static ActionTween SetAutoKill(this ActionTween tween, bool autoKill) { tween.mAutoKill = autoKill; return(tween); }
/// <summary> /// 每次Loop完回调一次,最后一次循环不会触发此函数,直接触发OnComplete函数 /// </summary> /// <param name="tween"></param> /// <param name="callback"></param> /// <returns></returns> public static ActionTween SetLoopCompleteCallback(this ActionTween tween, ActionTweenCallback callback) { tween.mOnLoopComplete = callback; return(tween); }
private void MakeForKilling(ActionTween t) { t.mKill = true; mWillKillTweens.Add(t); }