public void QuitAnim(UIAnimType animType, UnityAction onComplete) { ResetAnim(animType); if (onComplete != null) { tween.AddOnFinished(onComplete); } tween.ResetToComplete(); tween.PlayReverse(); }
public void EnterAnim(UIAnimType animType, UnityAction onComplete) { ResetAnim(animType); if (onComplete != null) { tween.AddOnFinished(onComplete); } tween.ResetToBeginning(); tween.PlayForward(); }
void InitTween() { for (int i = 0; i < LayerContainerList.Count; i++) { //UILayerContainer<AnimEntry> layerContainer = LayerContainerList[i]; UILayerContainerAnim layerContainer = LayerContainerList[i]; for (int j = 0; j < layerContainer.ChildList.Count; j++) { AnimEntry animEntry = layerContainer.ChildList[j]; UIAnimType animType = animEntry.Type; if (animType == UIAnimType.Position) { animEntry.tween = TweenPos.Tween(gameObject, animEntry.Duration, animEntry.To); } if (animType == UIAnimType.Scale) { animEntry.tween = TweenScale.Tween(gameObject, animEntry.Duration, animEntry.To); } if (animType != UIAnimType.None) { animEntry.tween.tweenFactor = 0; animEntry.tween.enabled = false; } /* * // 在这里继续添加其他类型的 */ // 这里就是让ChildList按顺序去播放 if (j > 0) { AnimEntry preAnimEntry = layerContainer.ChildList[j - 1]; AddTweenListener(preAnimEntry, animEntry); } // 添加回调,在最后一个动作回调 if (j == layerContainer.ChildList.Count - 1) { AnimEntry lastAnimEntry = layerContainer.ChildList[j]; AddLastTweenCallback(layerContainer.Type, lastAnimEntry); } } } }
private void ResetAnim(UIAnimType animType) { switch (animType) { case UIAnimType.ScalePanel: tween = uTweenScale.Begin(panel, Vector3.one * 0.8f, Vector3.one, duration); break; case UIAnimType.PosUpPanel: tween = uTweenPosition.Begin(panel, Vector3.left * 200, Vector3.zero, duration); break; case UIAnimType.RotatePanel: tween = uTweenRotation.Begin(panel, Vector3.up * 30, Vector3.zero, duration); break; default: break; } }