public static float EaseFromTo(float start, float end, float value, eEaseType type = eEaseType.EaseInOut) { switch (type) { case eEaseType.EaseInOut: return(Mathf.Lerp(start, end, value * value * (3.0f - 2.0f * value))); case eEaseType.EaseOut: return(Mathf.Lerp(start, end, Mathf.Sin(value * Mathf.PI * 0.5f))); case eEaseType.EaseIn: return(Mathf.Lerp(start, end, 1.0f - Mathf.Cos(value * Mathf.PI * 0.5f))); default: return(Mathf.Lerp(start, end, value)); } }
// 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); }
public static Func <float, float> GetEaseFunc(eEaseType ease) { Func <float, float> func = null; switch (ease) { case eEaseType.QuadIn: if (sEaseInQuad == null) { sEaseInQuad = EaseInQuad; } func = EaseInQuad; break; case eEaseType.QuadOut: if (sEaseOutQuad == null) { sEaseOutQuad = EaseOutQuad; } func = EaseOutQuad; break; case eEaseType.QuadInOut: if (sEaseInOutQuad == null) { sEaseInOutQuad = EaseInOutQuad; } func = EaseInOutQuad; break; case eEaseType.QuadOutIn: if (sEaseOutInQuad == null) { sEaseOutInQuad = EaseOutInQuad; } func = EaseOutInQuad; break; case eEaseType.CubicIn: if (sEaseInCubic == null) { sEaseInCubic = EaseInCubic; } func = EaseInCubic; break; case eEaseType.CubicOut: if (sEaseOutCubic == null) { sEaseOutCubic = EaseOutCubic; } func = EaseOutCubic; break; case eEaseType.CubicInOut: if (sEaseInOutCubic == null) { sEaseInOutCubic = EaseInOutCubic; } func = EaseInOutCubic; break; case eEaseType.CubicOutIn: if (sEaseOutInCubic == null) { sEaseOutInCubic = EaseOutInCubic; } func = EaseOutInCubic; break; case eEaseType.QuartIn: if (sEaseInQuart == null) { sEaseInQuart = EaseInQuart; } func = EaseInQuart; break; case eEaseType.QuartOut: if (sEaseOutQuart == null) { sEaseOutQuart = EaseOutQuart; } func = EaseOutQuart; break; case eEaseType.QuartInOut: if (sEaseInOutQuart == null) { sEaseInOutQuart = EaseInOutQuart; } func = EaseInOutQuart; break; case eEaseType.QuartOutIn: if (sEaseOutInQuart == null) { sEaseOutInQuart = EaseOutInQuart; } func = EaseOutInQuart; break; case eEaseType.QuintIn: if (sEaseInQuint == null) { sEaseInQuint = EaseInQuint; } func = EaseInQuint; break; case eEaseType.QuintOut: if (sEaseOutQuint == null) { sEaseOutQuint = EaseOutQuint; } func = EaseOutQuint; break; case eEaseType.QuintInOut: if (sEaseInOutQuint == null) { sEaseInOutQuint = EaseInOutQuint; } func = EaseInOutQuint; break; case eEaseType.QuintOutIn: if (sEaseOutInQuint == null) { sEaseOutInQuint = EaseOutInQuint; } func = EaseOutInQuint; break; case eEaseType.ExpoIn: if (sEaseInExpo == null) { sEaseInExpo = EaseInExpo; } func = EaseInExpo; break; case eEaseType.ExpoOut: if (sEaseOutExpo == null) { sEaseOutExpo = EaseOutExpo; } func = EaseOutExpo; break; case eEaseType.ExpoInOut: if (sEaseInOutExpo == null) { sEaseInOutExpo = EaseInOutExpo; } func = EaseInOutExpo; break; case eEaseType.ExpoOutIn: if (sEaseOutInExpo == null) { sEaseOutInExpo = EaseOutInExpo; } func = EaseOutInExpo; break; case eEaseType.CircIn: if (sEaseInCirc == null) { sEaseInCirc = EaseInCirc; } func = EaseInCirc; break; case eEaseType.CircOut: if (sEaseOutCirc == null) { sEaseOutCirc = EaseOutCirc; } func = EaseOutCirc; break; case eEaseType.CircInOut: if (sEaseInOutCirc == null) { sEaseInOutCirc = EaseInOutCirc; } func = EaseInOutCirc; break; case eEaseType.CircOutIn: if (sEaseOutInCirc == null) { sEaseOutInCirc = EaseOutInCirc; } func = EaseOutInCirc; break; case eEaseType.SineIn: if (sEaseInSine == null) { sEaseInSine = EaseInSine; } func = EaseInSine; break; case eEaseType.SineOut: if (sEaseOutSine == null) { sEaseOutSine = EaseOutSine; } func = EaseOutSine; break; case eEaseType.SineInOut: if (sEaseInOutSine == null) { sEaseInOutSine = EaseInOutSine; } func = EaseInOutSine; break; case eEaseType.SineOutIn: if (sEaseOutInSine == null) { sEaseOutInSine = EaseOutInSine; } func = EaseOutInSine; break; case eEaseType.ElasticIn: if (sEaseInElastic == null) { sEaseInElastic = EaseInElastic; } func = EaseInElastic; break; case eEaseType.ElasticOut: if (sEaseOutElastic == null) { sEaseOutElastic = EaseOutElastic; } func = EaseOutElastic; break; case eEaseType.ElasticInOut: if (sEaseInOutElastic == null) { sEaseInOutElastic = EaseInOutElastic; } func = EaseInOutElastic; break; case eEaseType.ElasticOutIn: if (sEaseOutInElastic == null) { sEaseOutInElastic = EaseOutInElastic; } func = EaseOutInElastic; break; case eEaseType.BounceIn: if (sEaseInBounce == null) { sEaseInBounce = EaseInBounce; } func = EaseInBounce; break; case eEaseType.BounceOut: if (sEaseOutBounce == null) { sEaseOutBounce = EaseOutBounce; } func = EaseOutBounce; break; case eEaseType.BounceInOut: if (sEaseInOutBounce == null) { sEaseInOutBounce = EaseInOutBounce; } func = EaseInOutBounce; break; case eEaseType.BounceOutIn: if (sEaseOutInBounce == null) { sEaseOutInBounce = EaseOutInBounce; } func = EaseOutInBounce; break; case eEaseType.BackIn: if (sEaseInBack == null) { sEaseInBack = EaseInBack; } func = EaseInBack; break; case eEaseType.BackOut: if (sEaseOutBack == null) { sEaseOutBack = EaseOutBack; } func = EaseOutBack; break; case eEaseType.BackInOut: if (sEaseInOutBack == null) { sEaseInOutBack = EaseInOutBack; } func = EaseInOutBack; break; case eEaseType.BackOutIn: if (sEaseOutInBack == null) { sEaseOutInBack = EaseOutInBack; } func = EaseOutInBack; break; } if (func != null) { return(func); } if (sEaseLinear == null) { sEaseLinear = EaseLinear; } return(sEaseLinear); }
// ###################################################################### // EaseType Converter for DOTween/HOTween/LeanTween/iTween // ###################################################################### #region EaseType Converter #if DOTWEEN // DOTween: https://www.assetstore.unity3d.com/en/#!/content/27676 // DOTween Documentation: http://dotween.demigiant.com/documentation.php public Ease DOTweenEaseType(eEaseType easeType) { Ease result = Ease.Linear; switch (easeType) { case eEaseType.InQuad: result = Ease.InQuad; break; case eEaseType.OutQuad: result = Ease.OutQuad; break; case eEaseType.InOutQuad: result = Ease.InOutQuad; break; case eEaseType.InCubic: result = Ease.OutCubic; break; case eEaseType.OutCubic: result = Ease.OutCubic; break; case eEaseType.InOutCubic: result = Ease.InOutCubic; break; case eEaseType.InQuart: result = Ease.InQuart; break; case eEaseType.OutQuart: result = Ease.OutQuart; break; case eEaseType.InOutQuart: result = Ease.InOutQuart; break; case eEaseType.InQuint: result = Ease.InQuint; break; case eEaseType.OutQuint: result = Ease.OutQuint; break; case eEaseType.InOutQuint: result = Ease.InOutQuint; break; case eEaseType.InSine: result = Ease.InSine; break; case eEaseType.OutSine: result = Ease.OutSine; break; case eEaseType.InOutSine: result = Ease.InOutSine; break; case eEaseType.InExpo: result = Ease.InExpo; break; case eEaseType.OutExpo: result = Ease.OutExpo; break; case eEaseType.InOutExpo: result = Ease.InOutExpo; break; case eEaseType.InCirc: result = Ease.InCirc; break; case eEaseType.OutCirc: result = Ease.OutCirc; break; case eEaseType.InOutCirc: result = Ease.InOutCirc; break; case eEaseType.linear: result = Ease.Linear; break; case eEaseType.InBounce: result = Ease.InBounce; break; case eEaseType.OutBounce: result = Ease.OutBounce; break; case eEaseType.InOutBounce: result = Ease.InOutBounce; break; case eEaseType.InBack: result = Ease.InBack; break; case eEaseType.OutBack: result = Ease.OutBack; break; case eEaseType.InOutBack: result = Ease.InOutBack; break; case eEaseType.InElastic: result = Ease.InElastic; break; case eEaseType.OutElastic: result = Ease.OutElastic; break; case eEaseType.InOutElastic: result = Ease.InOutElastic; break; default: result = Ease.Linear; break; } return result; }
// iTween: https://www.assetstore.unity3d.com/#/content/84 // iTween Documentation: http://itween.pixelplacement.com/documentation.php public string iTweenEaseType(eEaseType easeType) { string result = "linear"; switch (easeType) { case eEaseType.InQuad: result = "easeInQuad"; break; case eEaseType.OutQuad: result = "easeOutQuad"; break; case eEaseType.InOutQuad: result = "easeInOutQuad"; break; case eEaseType.InCubic: result = "easeOutCubic"; break; case eEaseType.OutCubic: result = "easeOutCubic"; break; case eEaseType.InOutCubic: result = "easeInOutCubic"; break; case eEaseType.InQuart: result = "easeInQuart"; break; case eEaseType.OutQuart: result = "easeOutQuart"; break; case eEaseType.InOutQuart: result = "easeInOutQuart"; break; case eEaseType.InQuint: result = "easeInQuint"; break; case eEaseType.OutQuint: result = "easeOutQuint"; break; case eEaseType.InOutQuint: result = "easeInOutQuint"; break; case eEaseType.InSine: result = "easeInSine"; break; case eEaseType.OutSine: result = "easeOutSine"; break; case eEaseType.InOutSine: result = "easeInOutSine"; break; case eEaseType.InExpo: result = "easeInExpo"; break; case eEaseType.OutExpo: result = "easeOutExpo"; break; case eEaseType.InOutExpo: result = "easeInOutExpo"; break; case eEaseType.InCirc: result = "easeInCirc"; break; case eEaseType.OutCirc: result = "easeOutCirc"; break; case eEaseType.InOutCirc: result = "easeInOutCirc"; break; case eEaseType.linear: result = "linear"; break; case eEaseType.InBounce: result = "easeInBounce"; break; case eEaseType.OutBounce: result = "easeOutBounce"; break; case eEaseType.InOutBounce: result = "easeInOutBounce"; break; case eEaseType.InBack: result = "easeInBack"; break; case eEaseType.OutBack: result = "easeOutBack"; break; case eEaseType.InOutBack: result = "easeInOutBack"; break; case eEaseType.InElastic: result = "easeInElastic"; break; case eEaseType.OutElastic: result = "easeOutElastic"; break; case eEaseType.InOutElastic: result = "easeInOutElastic"; break; default: result = "linear"; break; } return result; }
public static string EaseTypeConvert(eEaseType easeType) { string result = "linear"; switch (easeType) { case eEaseType.InQuad: result = "EaseInQuad"; break; case eEaseType.OutQuad: result = "EaseOutQuad"; break; case eEaseType.InOutQuad: result = "EaseInOutQuad"; break; case eEaseType.InCubic: result = "EaseOutCubic"; break; case eEaseType.OutCubic: result = "EaseOutCubic"; break; case eEaseType.InOutCubic: result = "EaseInOutCubic"; break; case eEaseType.InQuart: result = "EaseInQuart"; break; case eEaseType.OutQuart: result = "EaseOutQuart"; break; case eEaseType.InOutQuart: result = "EaseInOutQuart"; break; case eEaseType.InQuint: result = "EaseInQuint"; break; case eEaseType.OutQuint: result = "EaseOutQuint"; break; case eEaseType.InOutQuint: result = "EaseInOutQuint"; break; case eEaseType.InSine: result = "EaseInSine"; break; case eEaseType.OutSine: result = "EaseOutSine"; break; case eEaseType.InOutSine: result = "EaseInOutSine"; break; case eEaseType.InExpo: result = "EaseInExpo"; break; case eEaseType.OutExpo: result = "EaseOutExpo"; break; case eEaseType.InOutExpo: result = "EaseInOutExpo"; break; case eEaseType.InCirc: result = "EaseInCirc"; break; case eEaseType.OutCirc: result = "EaseOutCirc"; break; case eEaseType.InOutCirc: result = "EaseInOutCirc"; break; case eEaseType.linear: result = "Linear"; break; case eEaseType.InBounce: result = "EaseInBounce"; break; case eEaseType.OutBounce: result = "EaseOutBounce"; break; case eEaseType.InOutBounce: result = "EaseInOutBounce"; break; case eEaseType.InBack: result = "EaseInBack"; break; case eEaseType.OutBack: result = "EaseOutBack"; break; case eEaseType.InOutBack: result = "EaseInOutBack"; break; case eEaseType.InElastic: result = "EaseInElastic"; break; case eEaseType.OutElastic: result = "EaseOutElastic"; break; case eEaseType.InOutElastic: result = "EaseInOutElastic"; break; default: result = "Linear"; break; } return(result); }
public static LeanTweenType EaseTypeConvert(eEaseType easeType) { LeanTweenType result = LeanTweenType.linear; switch (easeType) { case eEaseType.InQuad: result = LeanTweenType.easeInQuad; break; case eEaseType.OutQuad: result = LeanTweenType.easeOutQuad; break; case eEaseType.InOutQuad: result = LeanTweenType.easeInOutQuad; break; case eEaseType.InCubic: result = LeanTweenType.easeOutCubic; break; case eEaseType.OutCubic: result = LeanTweenType.easeOutCubic; break; case eEaseType.InOutCubic: result = LeanTweenType.easeInOutCubic; break; case eEaseType.InQuart: result = LeanTweenType.easeInQuart; break; case eEaseType.OutQuart: result = LeanTweenType.easeOutQuart; break; case eEaseType.InOutQuart: result = LeanTweenType.easeInOutQuart; break; case eEaseType.InQuint: result = LeanTweenType.easeInQuint; break; case eEaseType.OutQuint: result = LeanTweenType.easeOutQuint; break; case eEaseType.InOutQuint: result = LeanTweenType.easeInOutQuint; break; case eEaseType.InSine: result = LeanTweenType.easeInSine; break; case eEaseType.OutSine: result = LeanTweenType.easeOutSine; break; case eEaseType.InOutSine: result = LeanTweenType.easeInOutSine; break; case eEaseType.InExpo: result = LeanTweenType.easeInExpo; break; case eEaseType.OutExpo: result = LeanTweenType.easeOutExpo; break; case eEaseType.InOutExpo: result = LeanTweenType.easeInOutExpo; break; case eEaseType.InCirc: result = LeanTweenType.easeInCirc; break; case eEaseType.OutCirc: result = LeanTweenType.easeOutCirc; break; case eEaseType.InOutCirc: result = LeanTweenType.easeInOutCirc; break; case eEaseType.linear: result = LeanTweenType.linear; break; case eEaseType.InBounce: result = LeanTweenType.easeInBounce; break; case eEaseType.OutBounce: result = LeanTweenType.easeOutBounce; break; case eEaseType.InOutBounce: result = LeanTweenType.easeInOutBounce; break; case eEaseType.InBack: result = LeanTweenType.easeInBack; break; case eEaseType.OutBack: result = LeanTweenType.easeOutBack; break; case eEaseType.InOutBack: result = LeanTweenType.easeInOutBack; break; case eEaseType.InElastic: result = LeanTweenType.easeInElastic; break; case eEaseType.OutElastic: result = LeanTweenType.easeOutElastic; break; case eEaseType.InOutElastic: result = LeanTweenType.easeInOutElastic; break; default: result = LeanTweenType.linear; break; } return(result); }
// ######################################## // EaseType Converter Functions // ######################################## #region EaseType Converter Functions #if USE_DOTWEEN // use DOTween: https://www.assetstore.unity3d.com/en/#!/content/27676 Documentation: http://dotween.demigiant.com/documentation.php // DOTween: https://www.assetstore.unity3d.com/en/#!/content/27676 // DOTween Documentation: http://dotween.demigiant.com/documentation.php public static Ease DOTweenEaseType(eEaseType easeType) { Ease result = Ease.Linear; switch (easeType) { case eEaseType.InQuad: result = Ease.InQuad; break; case eEaseType.OutQuad: result = Ease.OutQuad; break; case eEaseType.InOutQuad: result = Ease.InOutQuad; break; case eEaseType.InCubic: result = Ease.OutCubic; break; case eEaseType.OutCubic: result = Ease.OutCubic; break; case eEaseType.InOutCubic: result = Ease.InOutCubic; break; case eEaseType.InQuart: result = Ease.InQuart; break; case eEaseType.OutQuart: result = Ease.OutQuart; break; case eEaseType.InOutQuart: result = Ease.InOutQuart; break; case eEaseType.InQuint: result = Ease.InQuint; break; case eEaseType.OutQuint: result = Ease.OutQuint; break; case eEaseType.InOutQuint: result = Ease.InOutQuint; break; case eEaseType.InSine: result = Ease.InSine; break; case eEaseType.OutSine: result = Ease.OutSine; break; case eEaseType.InOutSine: result = Ease.InOutSine; break; case eEaseType.InExpo: result = Ease.InExpo; break; case eEaseType.OutExpo: result = Ease.OutExpo; break; case eEaseType.InOutExpo: result = Ease.InOutExpo; break; case eEaseType.InCirc: result = Ease.InCirc; break; case eEaseType.OutCirc: result = Ease.OutCirc; break; case eEaseType.InOutCirc: result = Ease.InOutCirc; break; case eEaseType.linear: result = Ease.Linear; break; case eEaseType.InBounce: result = Ease.InBounce; break; case eEaseType.OutBounce: result = Ease.OutBounce; break; case eEaseType.InOutBounce: result = Ease.InOutBounce; break; case eEaseType.InBack: result = Ease.InBack; break; case eEaseType.OutBack: result = Ease.OutBack; break; case eEaseType.InOutBack: result = Ease.InOutBack; break; case eEaseType.InElastic: result = Ease.InElastic; break; case eEaseType.OutElastic: result = Ease.OutElastic; break; case eEaseType.InOutElastic: result = Ease.InOutElastic; break; default: result = Ease.Linear; break; } return(result); }