/// <summary>
 /// Sets the curve based on the ease type, using 'count' number of subdivisions.
 /// </summary>
 /// <returns>The curve.</returns>
 /// <param name="easeType">Ease type.</param>
 public static AnimationCurve GetCurve(UIAnimationUtility.EaseType easeType)
 {
     if (easeType == UIAnimationUtility.EaseType.Custom)
     {
         AnimationCurve newCurve = new AnimationCurve();
         newCurve.AddKey(new Keyframe(0, 0));
         newCurve.AddKey(new Keyframe(1f, 1f));
         return(newCurve);
     }
     else
     {
         UIAnimationUtility.EasingFunction easingFunction = UIAnimationUtility.GetEasingFunction(easeType);
         AnimationCurve newCurve = new AnimationCurve();
         int            count    = 25;
         for (int i = 0; i <= count; ++i)
         {
             float    percent = ((float)i) / ((float)count);
             float    value   = easingFunction(0, 1f, percent);
             Keyframe newKey  = new Keyframe(percent, value, 0, 0);
             newCurve.AddKey(newKey);
         }
         for (int i = 0; i <= count; ++i)
         {
             newCurve.SmoothTangents(i, 0);
         }
         return(newCurve);
     }
 }
        /// <summary>
        /// Draws the ease related GUI elements.
        /// </summary>
        protected void DrawEase()
        {
            EditorGUILayout.LabelField("Ease", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(easeType, new GUIContent("Ease Type"));
            currentEaseType = myUIAnimation.easeType;
            if (currentEaseType != myUIAnimation.lastEaseType)
            {
                currentCurve = UIAnimationUtility.GetCurve(currentEaseType);
            }

            myUIAnimation.lastEaseType = currentEaseType;
        }
        /// <summary>
        /// Draws the curve related GUI elements.
        /// </summary>
        protected void DrawCurve()
        {
            if (currentCurve == null)
            {
                currentCurve = myUIAnimation.easeCurve;
                if (currentCurve == null)
                {
                    currentCurve = UIAnimationUtility.GetCurve(currentEaseType);
                }
            }

            int curveHeight = Screen.width - 20;

            if (myUIAnimation.isCurveMinimized)
            {
                curveHeight = 40;
            }
            currentCurve = EditorGUILayout.CurveField(currentCurve, curveColor, new Rect(), GUILayout.Height(curveHeight));
            GUILayout.BeginHorizontal();
            //Reset curve to chosen animation type
            if (GUILayout.Button("Reset", EditorStyles.miniButtonLeft))
            {
                currentCurve = UIAnimationUtility.GetCurve(currentEaseType);
            }
            string resizeText = "Minimize";

            //Minimize/Maximize curve window
            if (myUIAnimation.isCurveMinimized)
            {
                resizeText = "Maximize";
            }
            if (GUILayout.Button(resizeText, EditorStyles.miniButtonRight))
            {
                myUIAnimation.isCurveMinimized = !myUIAnimation.isCurveMinimized;
            }
            GUILayout.EndHorizontal();
        }
 public void AddFillPercentRelativeAnimation(Action onCompleteAction, float deltaFillPercent, float duration, UIAnimationUtility.EaseType easeType, int loopCount = 0, UIAnimation_Base.LoopType loopType = UIAnimation_Base.LoopType.PingPong)
 {
     AddFillPercentAnimation(UIAnimation_Base.TweenType.Relative, onCompleteAction, 0, 0, deltaFillPercent, duration, UIAnimationUtility.GetCurve(easeType), loopType, loopCount);
 }
        //////////////////////////////
        // FillPercent Start/End/Relative Functions

        public void AddFillPercentStartAnimation(Action onCompleteAction, float startFillPercent, float endFillPercent, float duration, UIAnimationUtility.EaseType easeType, int loopCount = 0, UIAnimation_Base.LoopType loopType = UIAnimation_Base.LoopType.PingPong)
        {
            AddFillPercentAnimation(UIAnimation_Base.TweenType.Start, onCompleteAction, startFillPercent, endFillPercent, 0, duration, UIAnimationUtility.GetCurve(easeType), loopType, loopCount);
        }
        public void AddColorEndAnimation(Color endColor, string propertyName = "_Color", float duration = 2f, UIAnimationUtility.EaseType easeType = UIAnimationUtility.EaseType.easeInSine, int loopCount = 0, UIAnimation_Base.LoopType loopType = UIAnimation_Base.LoopType.PingPong, Action onCompleteAction = null)
        {
            MaterialAnimation.ColorData colorData = new MaterialAnimation.ColorData();
            colorData.endColor     = endColor;
            colorData.propertyName = propertyName;

            AddColorAnimation(UIAnimation_Base.TweenType.End, onCompleteAction, colorData, duration, UIAnimationUtility.GetCurve(easeType), loopType, loopCount);
        }
        public void AddFloatRelativeAnimation(float deltaValue, string propertyName = "_AlphaMultiplier", float duration = 2f, UIAnimationUtility.EaseType easeType = UIAnimationUtility.EaseType.easeInSine, int loopCount = 0, UIAnimation_Base.LoopType loopType = UIAnimation_Base.LoopType.PingPong, Action onCompleteAction = null)
        {
            MaterialAnimation.FloatData floatData = new MaterialAnimation.FloatData();
            floatData.deltaValue   = deltaValue;
            floatData.propertyName = propertyName;

            AddFloatAnimation(UIAnimation_Base.TweenType.Relative, onCompleteAction, floatData, duration, UIAnimationUtility.GetCurve(easeType), loopType, loopCount);
        }
 public void AddPositionRelativeAnimation(Vector3 deltaPosition, float duration, UIAnimationUtility.EaseType easeType, Action onCompleteAction = null, Action <float> onUpdateAction = null, int loopCount = 0, UIAnimation_Base.LoopType loopType = UIAnimation_Base.LoopType.PingPong)
 {
     AddPositionAnimation(UIAnimation_Base.TweenType.Relative, onCompleteAction, onUpdateAction, Vector3.zero, Vector3.zero, deltaPosition, duration, UIAnimationUtility.GetCurve(easeType), loopType, loopCount);
 }
        //////////////////////////////
        // Position Start/End/Relative Functions

        public void AddPositionStartAnimation(Vector3 startPosition, Vector3 endPosition, float duration, UIAnimationUtility.EaseType easeType, Action onCompleteAction = null, Action <float> onUpdateAction = null, int loopCount = 0, UIAnimation_Base.LoopType loopType = UIAnimation_Base.LoopType.PingPong)
        {
            AddPositionAnimation(UIAnimation_Base.TweenType.Start, onCompleteAction, onUpdateAction, startPosition, endPosition, Vector3.zero, duration, UIAnimationUtility.GetCurve(easeType), loopType, loopCount);
        }
 public void AddScaleEndAnimation(Vector3 endScale, float duration, UIAnimationUtility.EaseType easeType, Action onCompleteAction = null, Action <float> onUpdateAction = null, int loopCount = 0, UIAnimation_Base.LoopType loopType = UIAnimation_Base.LoopType.PingPong)
 {
     AddScaleAnimation(UIAnimation_Base.TweenType.End, onCompleteAction, onUpdateAction, Vector3.zero, endScale, Vector3.zero, duration, UIAnimationUtility.GetCurve(easeType), loopType, loopCount);
 }
 public void AddRotationRelativeAnimation(Quaternion deltaRotation, float duration, UIAnimationUtility.EaseType easeType, Action onCompleteAction = null, Action <float> onUpdateAction = null, int loopCount = 0, UIAnimation_Base.LoopType loopType = UIAnimation_Base.LoopType.PingPong)
 {
     AddRotationAnimation(UIAnimation_Base.TweenType.Relative, onCompleteAction, onUpdateAction, Quaternion.identity, Quaternion.identity, deltaRotation, duration, UIAnimationUtility.GetCurve(easeType), loopType, loopCount);
 }
 public void AddRepetitionsEndAnimation(Action onCompleteAction, float endRepetitions, float duration, UIAnimationUtility.EaseType easeType, int loopCount = 0, UIAnimation_Base.LoopType loopType = UIAnimation_Base.LoopType.PingPong)
 {
     AddRepetitionsAnimation(UIAnimation_Base.TweenType.End, onCompleteAction, 0, endRepetitions, 0, duration, UIAnimationUtility.GetCurve(easeType), loopType, loopCount);
 }
예제 #13
0
 public void AddColorEndAnimation(Action onCompleteAction, Color endColor, float duration, UIAnimationUtility.EaseType easeType, int loopCount = 0, UIAnimation_Base.LoopType loopType = UIAnimation_Base.LoopType.PingPong)
 {
     AddColorAnimation(UIAnimation_Base.TweenType.End, onCompleteAction, Color.white, endColor, Color.white, duration, UIAnimationUtility.GetCurve(easeType), loopType, loopCount);
 }