private void GoToPos(RectTransform rectTran, Vector2 pos) { MyTweenRectPosition mytween = rectTran.GetComponent <MyTweenRectPosition>(); if (mytween == null) { mytween = rectTran.gameObject.AddComponent <MyTweenRectPosition>(); } mytween.from = rectTran.anchoredPosition3D; mytween.to = pos; mytween.ResetToBeginning(); mytween.worldSpace = false; mytween.duration = 0.5f; mytween.PlayForward(); //停掉当前动画 ///开始动画 从当前位置 返回到 本地坐标初始位置 }
private void goBack(RectTransform rectTran) { MyTweenRectPosition mytween = rectTran.GetComponent <MyTweenRectPosition>(); if (mytween == null) { mytween = rectTran.gameObject.AddComponent <MyTweenRectPosition>(); } mytween.from = rectTran.anchoredPosition3D; mytween.to = Vector2.zero; mytween.ResetToBeginning(); mytween.worldSpace = false; mytween.style = Style.Once; mytween.moveType = MoveType.EaseInOut; mytween.duration = 0.5f; mytween.PlayForward(); //停掉当前动画 ///开始动画 从当前位置 返回到 本地坐标初始位置 }
private void GoToWorldPos(RectTransform rectTran, Vector2 pos) { MyTweenRectPosition mytween = rectTran.GetComponent <MyTweenRectPosition>(); if (mytween == null) { mytween = rectTran.gameObject.AddComponent <MyTweenRectPosition>(); } mytween.from = rectTran.position; mytween.to = pos; mytween.ResetToBeginning(); mytween.worldSpace = true; mytween.style = Style.Once; mytween.moveType = MoveType.EaseInOut; mytween.duration = 0.5f; mytween.PlayForward(); //停掉当前动画 //动画 从当前位置 去到指定位置 }