コード例 #1
0
 IEnumerator ShowAndRotatePanelWhenPossible(RectTransform thisRectTransform, Vector3 axis, float finalRotation, float duration, Vector3 rotationPivot)
 {
     Debug.Log("ShowAndRotatePanelWhenPossible()");
     thisRectTransform.gameObject.SetActive(false);
     while (!finishedRotationAnimation) yield return null;
     float flipDelta = GetPanelFlipDelta(thisRectTransform, axis, rotationPivot);
     thisRectTransform.gameObject.SetActive(false);
     thisRectTransform.localRotation = Quaternion.identity;
     thisRectTransform.RotateAround(rotationPivot, axis, 270f + flipDelta);
     thisRectTransform.gameObject.SetActive(true);
     StartCoroutine(PlayRotationAnimation(thisRectTransform, axis, finalRotation, duration, rotationPivot));
     //tabManager.busyWithPanelAnimation = false;
     if (addAlphaTweenEffect)
     {
         CanvasGroup thisCanvasGroup = thisRectTransform.gameObject.GetComponent<CanvasGroup>();
         thisCanvasGroup.alpha = 0.0f;
         StartCoroutine(PlayAlphaAnimation(thisCanvasGroup, 1.0f, duration/4));
     }
 }
コード例 #2
0
 // Rotation animation responsible for swapping the panels.
 IEnumerator PlayRotationAnimation(RectTransform thisRectTransform, Vector3 axis, float finalRotation, float duration, Vector3 rotationPivot)
 {
     if (!tabManager.busyWithPanelAnimation) tabManager.busyWithPanelAnimation = true;
     else readyToVacate = true;
     finishedRotationAnimation = false;
     float initialRotation = 0.0f, stepDuration = 0.1f;
     // Get Current Rotation
     initialRotation = GetRTAngleByAxis(thisRectTransform, axis);
     Debug.Log("PlayRotationAnimation(" + thisRectTransform.name + ": " + initialRotation + " -> " + finalRotation + ")");
     // Execute Animation
     for (float currentDuration=0; currentDuration<duration; currentDuration+=stepDuration)
     {
         float progress = currentDuration/duration;
         float easeProgress = (Mathf.Sin((-90f + 180f*progress)*Mathf.Deg2Rad)+1f)*0.5f;
         float rotationAngle = initialRotation + easeProgress * DistanceBetweenAngles(finalRotation, initialRotation);
         thisRectTransform.localRotation = Quaternion.identity;
         thisRectTransform.RotateAround(rotationPivot, axis, rotationAngle);
         yield return new WaitForSeconds(stepDuration);
     }
     thisRectTransform.localRotation = Quaternion.identity;
     thisRectTransform.RotateAround(rotationPivot, axis, finalRotation);
     finishedRotationAnimation = true;
     if (readyToVacate)
     {
         tabManager.busyWithPanelAnimation = false;
         readyToVacate = false;
     }
 }