// Play Animations void Play() { // Random Time and Delay float Time = UnityEngine.Random.Range(m_MinRandomTime, m_MinRandomTime + 2); float Delay = UnityEngine.Random.Range(m_MinRandomDelay, m_MinRandomDelay + 0.5f); // Reset m_Title and m_Details strings m_Title = ""; m_Details = ""; // Random Ease type eEaseType EaseType = (eEaseType)UnityEngine.Random.Range(0, 22); // Translation checkbox is enable if (m_Translation == true) { // Get parent Canvas space float LeftEdge = 0, TopEdge = 0, RightEdge = 0, BottomEdge = 0; m_GAui.GetParentCanvasEdges(out LeftEdge, out TopEdge, out RightEdge, out BottomEdge); // Random Easing for Translation if m_UseSameEasing is disabled if (m_UseSameEasing == false) { EaseType = (eEaseType)UnityEngine.Random.Range(0, 22); } // Update Text UI m_Title += "Translation:\r\n"; m_Details += EaseType.ToString() + "\r\n"; // Setup begin and end position RectTransform RT = (RectTransform)m_GAui.transform; Vector3 Begin = new Vector3(RT.localPosition.x, RT.localPosition.y, 0); float NewEndX = 0; Bounds TotalBounds = m_GAui.GetTotalBounds(); if (RT.localPosition.x > 0) { NewEndX = LeftEdge + (TotalBounds.size.x * 2); } else { NewEndX = RightEdge - (TotalBounds.size.x * 2); } Vector3 End = new Vector3( NewEndX, UnityEngine.Random.Range(BottomEdge + TotalBounds.size.y * 2, TopEdge - TotalBounds.size.y * 2), 0); // Set MoveIn, we will call PlayInAnims() later m_GAui.SetInAnimsMove(true, ePosMove.RectTransformPosition, Begin, End, Time, Delay, EaseType); } else { // Update Text UI m_Title += "Translation:\r\n"; m_Details += "-\r\n"; // Disable MoveIn m_GAui.SetInAnimsMove(false); } // Rotation checkbox is enable if (m_Rotation == true) { // Random Easing for Translation if m_UseSameEasing is disabled if (m_UseSameEasing == false) { EaseType = (eEaseType)UnityEngine.Random.Range(0, 22); } // Update m_Title and m_Details strings m_Title += "Rotation:\r\n"; m_Details += EaseType.ToString() + "\r\n"; // Setup begin and end rotation Vector3 Begin = new Vector3(0, 0, 0); Vector3 End = new Vector3(0, 0, 360); // Set RotateIn, we will call PlayInAnims() later m_GAui.SetInAnimsRotate(true, Begin, End, Time, Delay, EaseType); } else { // Update m_Title and m_Details strings m_Title += "Rotation:\r\n"; m_Details += "-\r\n"; // Disable RotateIn m_GAui.SetInAnimsRotate(false); } // Scale checkbox is enable if (m_Scale == true) { // Random Easing for Translation if m_UseSameEasing is disabled if (m_UseSameEasing == false) { EaseType = (eEaseType)UnityEngine.Random.Range(0, 22); } // Update m_Title and m_Details strings m_Title += "Scale:\r\n"; m_Details += EaseType.ToString() + "\r\n"; // Setup begin and end scale Vector3 Begin = new Vector3(0, 0, 0); // Set RotateIn, we will call PlayInAnims() later m_GAui.SetInAnimsScale(true, Begin, Time, Delay, EaseType); } else { // Update m_Title and m_Details strings m_Title += "Scale:\r\n"; m_Details += "-\r\n"; // Disable ScaleIn m_GAui.SetInAnimsScale(false); } // Fade checkbox is enable if (m_Fade == true) { // Random Easing for Translation if m_UseSameEasing is disabled if (m_UseSameEasing == false) { EaseType = (eEaseType)UnityEngine.Random.Range(0, 22); } // Update m_Title and m_Details strings m_Title += "Fade:\r\n"; m_Details += EaseType.ToString() + "\r\n"; // Set RotateIn, we will call PlayInAnims() later m_GAui.SetInAnimsFade(true, Time, Delay, EaseType); } else { // Update m_Title and m_Details strings m_Title += "Fade:\r\n"; m_Details += "-\r\n"; // Disable RotateIn m_GAui.SetInAnimsFade(false); } // ShowTimeAndDelay checkbox is enable if (m_ShowTimeAndDelay == true) { // Update m_Title and m_Details strings m_Title += "Time:\r\nDelay:\r\n"; m_Details += string.Format("{0:0.0}", Time) + " secs" + "\r\n" + string.Format("{0:0.0}", Delay) + " secs" + "\r\n"; } if (m_TextTitle != null && m_TextDetails != null) { // Update Text UI m_TextTitle.text = m_Title; m_TextDetails.text = m_Details; } // Play In-animations m_GAui.PlayInAnims(eGUIMove.Self); }