private void DoFadeAndMove(MaskableGraphic trans, float fadeTime, float moveTime, Vector3 moveTarget, Action onFinished) { DoTweenHelper.DoFade(trans, 1, fadeTime, Ease.Flash, null); DoTweenHelper.DoLocalMove(trans.transform, moveTarget, moveTime, Ease.Flash, () => { if (onFinished != null) { onFinished(); } }); }
/// <summary> /// 执行翻页动画 /// </summary> /// <param name="clickKey"></param> private void DoPageTransMove(E_ClickKey clickKey) { //加载新界面数据 LoadNewPageData(clickKey); Transform currentPageItem = GetTheOtherPageTrans(_currentPageData.Trans); Transform theOtherPageItem = _currentPageData.Trans; Vector3 theOtherStartPos = default(Vector3); Vector3 theOtherTargetPos = CenterPosition; Vector3 curStartPos = CenterPosition; Vector3 curTargetPos = default(Vector3); Vector2 pageSize = PageTrans.GetComponent <RectTransform>().sizeDelta; switch (clickKey) { case E_ClickKey.Up: theOtherStartPos = new Vector3(0f, pageSize.y); curTargetPos = new Vector3(0f, -pageSize.y); break; case E_ClickKey.Down: theOtherStartPos = new Vector3(0f, -pageSize.y); curTargetPos = new Vector3(0f, pageSize.y); break; case E_ClickKey.Left: theOtherStartPos = new Vector3(-pageSize.x, 0f); curTargetPos = new Vector3(pageSize.x, 0f); break; case E_ClickKey.Right: theOtherStartPos = new Vector3(pageSize.x, 0f); curTargetPos = new Vector3(-pageSize.x, 0f); break; } currentPageItem.localPosition = curStartPos; theOtherPageItem.localPosition = theOtherStartPos; _isMoving = true; if (HandleMove != null) { HandleMove(); } EnablePageItemBtn(currentPageItem, false); // Debug.Log(currentPageItem.localPosition + " " + curTargetPos); // Debug.Log(theOtherPageItem.localPosition + " " + theOtherTargetPos); DoTweenHelper.DoLocalMove(currentPageItem, curTargetPos, 0.5f, EaseType, () => { EnablePageItemBtn(currentPageItem, true); }); DoTweenHelper.DoLocalMove(theOtherPageItem, theOtherTargetPos, 0.5f, EaseType, () => { _isMoving = false; if (HandleMoveComplete != null) { HandleMoveComplete(); } if (clickKey == E_ClickKey.Up || clickKey == E_ClickKey.Left) { for (int i = theOtherPageItem.childCount - 1; i >= 0; i--) { var item = theOtherPageItem.GetChild(i).gameObject; if (item.activeSelf) { UIController.instance.CurrentSelectedObj = item; break; } } } else if (clickKey == E_ClickKey.Down || clickKey == E_ClickKey.Right) { UIController.instance.CurrentSelectedObj = theOtherPageItem.GetChild(0).gameObject; } }); }