Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new SpriteRendererFadeAnimation (in a DelegateAnimation) using this renderer
        /// </summary>
        /// <param name="renderer">The renderer that will be the target of the animation</param>
        /// <param name="to">The end alpha value of the fade</param>
        /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
        /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
        /// <returns>A DelegateAnimation which contains the RendererFadeAnimation</returns>
        public static DelegateAnimation <SpriteRendererFadeAnimation> FadeTo(this SpriteRenderer renderer, float to, float duration = 1f, Func <float, float> easingFunction = null)
        {
            var animation = new DelegateAnimation <SpriteRendererFadeAnimation>(() =>
                                                                                new SpriteRendererFadeAnimation(renderer, renderer.color.a, to, duration, easingFunction));

            return(animation);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a ScaleAnimation that will scale to the given target scale, starting at the transform's current scale
        /// The current scale will be the transform's position when the animation playback commences and not the scale at the time of the creation of the animation
        /// </summary>
        /// <param name="transform">The transform that will be used in the ScaleAnimation</param>
        /// <param name="to">The end scale of the ScaleAnimation</param>
        /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
        /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
        /// <returns>The new created ScaleAnimation</returns>
        public static DelegateAnimation <ScaleAnimation> ScaleTo(this Transform transform, float to, float duration = 1f, Func <float, float> easingFunction = null)
        {
            var animation = new DelegateAnimation <ScaleAnimation>(() =>
                                                                   new ScaleAnimation(transform.gameObject, transform.localScale, Vector3.one * to, duration, easingFunction));

            return(animation);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new ColorShaderPropertyAnimation (in a DelegateAnimation) using this renderer
        /// </summary>
        /// <param name="renderer">The renderer that will be the target of the animation</param>
        /// <param name="shaderPropertyID">The ID of the target shader property</param>
        /// <param name="to">The end color of the fade</param>
        /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
        /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
        /// <returns>A DelegateAnimation which contains the created RendererColorFadeAnimation</returns>
        public static DelegateAnimation <ColorShaderPropertyAnimation> ColorFadeTo(this Renderer renderer, int shaderPropertyID, Color to, float duration = 1f, Func <float, float> easingFunction = null)
        {
            var animation = new DelegateAnimation <ColorShaderPropertyAnimation>(() =>
                                                                                 new ColorShaderPropertyAnimation(renderer, shaderPropertyID, renderer.material.GetColor(shaderPropertyID), to, duration, easingFunction));

            return(animation);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new UIColorFadeAnimation using a CanvasGroup using this Graphic
        /// </summary>
        /// <param name="graphic">The Graphic that will be the target of the animation</param>
        /// <param name="to">The end color of the fade</param>
        /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
        /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
        /// <returns>A DelegateAnimation which contains the created UIColorFadeAnimation</returns>
        public static DelegateAnimation <UIColorFadeAnimation> ColorFadeTo(this Graphic graphic, Color to, float duration = 1f, Func <float, float> easingFunction = null)
        {
            var animation = new DelegateAnimation <UIColorFadeAnimation>(() =>
                                                                         new UIColorFadeAnimation(graphic, graphic.color, to, duration, easingFunction));

            return(animation);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a RotateAnimation that will rotate the transform by the offset specified from it's current rotation.
        /// The current rotation will be the transform's rotation when the animation playback commences and not the rotation at the time of the creation of the animation
        /// </summary>
        /// <param name="transform">The transform that will be used in the MoveAnimation</param>
        /// <param name="offset">The offset or delta the animation will move the transform by</param>
        /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
        /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
        /// <returns>The newly created RotateAnimation</returns>
        public static DelegateAnimation <RotateAnimation> RotateRelative(this Transform transform, Vector3 offset, float duration = 1f, Func <float, float> easingFunction = null)
        {
            var animation = new DelegateAnimation <RotateAnimation>(() =>
                                                                    new RotateAnimation(
                                                                        transform.gameObject,
                                                                        transform.localEulerAngles,
                                                                        transform.localEulerAngles + offset,
                                                                        duration,
                                                                        easingFunction));

            return(animation);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a MoveAnimation that will move the anchor position of the rect transform by the offset specified from it's current position.
        /// The current position will be the transform's position when the animation playback commences and not the position at the time of the creation of the animation
        /// </summary>
        /// <param name="rectTransform">The rect transform that will be used in the MoveAnimation</param>
        /// <param name="offset">The offset or delta the animation will move the transform by</param>
        /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
        /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
        /// <returns>The newly created move Animation</returns>
        public static DelegateAnimation <MoveAnimation> MoveAnchorRelative(this RectTransform rectTransform, Vector3 offset, float duration = 1f, Func <float, float> easingFunction = null)
        {
            var animation = new DelegateAnimation <MoveAnimation>(() =>
                                                                  new MoveAnimation(
                                                                      rectTransform,
                                                                      rectTransform.anchoredPosition3D,
                                                                      rectTransform.anchoredPosition3D + offset,
                                                                      duration,
                                                                      easingFunction));

            return(animation);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a MoveAnimation that will move the transform by the offset specified from it's current position.
        /// The current position will be the transform's position when the animation playback commences and not the position at the time of the creation of the animation
        /// </summary>
        /// <param name="transform">The transform that will be used in the MoveAnimation</param>
        /// <param name="offset">The offset or delta the animation will move the transform by</param>
        /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
        /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
        /// <returns>The newly created move Animation</returns>
        public static DelegateAnimation <MoveAnimation> MoveRelative(this Transform transform, Vector3 offset, float duration = 1f, Func <float, float> easingFunction = null)
        {
            var animation = new DelegateAnimation <MoveAnimation>(() =>
                                                                  new MoveAnimation(
                                                                      transform.gameObject,
                                                                      transform.localPosition,
                                                                      transform.localPosition + offset,
                                                                      duration,
                                                                      easingFunction));

            return(animation);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a RotateAnimation that will rotate from the transform's current rotation to the specified rotation
        /// The current rotation will be the transform's rotation when the animation playback commences and not the rotation at the time of the creation of the animation
        /// </summary>
        /// <param name="transform">The transform that will be used in the RotateAnimation</param>
        /// <param name="to">The end rotation (local) of the RotateAnimation</param>
        /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
        /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
        /// <param name="useLocalRotation">Indicates if the animation will use localRotation</param>
        /// <returns>The newly created RotateAnimation</returns>
        public static DelegateAnimation <RotateAnimation> RotateTo(this Transform transform, Quaternion to, float duration = 1f, Func <float, float> easingFunction = null, bool useLocalRotation = false)
        {
            var animation = new DelegateAnimation <RotateAnimation>(() =>
                                                                    new RotateAnimation(
                                                                        transform.gameObject,
                                                                        useLocalRotation ? transform.localRotation : transform.rotation,
                                                                        to,
                                                                        duration,
                                                                        easingFunction,
                                                                        useLocalRotation));

            return(animation);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates MoveAnimation that will move from the transform's current position to the specified position
        /// The current position will be the transform's position when the animation playback commences and not the position at the time of the creation of the animation
        /// </summary>
        /// <param name="transform">The transform that will be used in the MoveAnimation</param>
        /// <param name="to">The end position (local) of the MoveAnimation</param>
        /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
        /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
        /// <param name="useLocalPosition">Indicates if the animation will use localPosition</param>
        /// <returns>The newly created move Animation</returns>
        public static DelegateAnimation <MoveAnimation> MoveTo(this Transform transform, Vector3 to, float duration = 1f, Func <float, float> easingFunction = null, bool useLocalPosition = false)
        {
            var animation = new DelegateAnimation <MoveAnimation>(() =>
                                                                  new MoveAnimation(
                                                                      transform.gameObject,
                                                                      useLocalPosition ? transform.localPosition : transform.position,
                                                                      to,
                                                                      duration,
                                                                      easingFunction,
                                                                      useLocalPosition));

            return(animation);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates a new MoveAnimation using 2 transforms
        /// </summary>
        /// <param name="transform">The transform that will be used in the MoveAnimation</param>
        /// <param name="from">The transform to use for the start position of the MoveAnimation</param>
        /// <param name="to">The transform to use for the end position of the MoveAnimation</param>
        /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
        /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
        /// <returns>The newly created move Animation</returns>
        public static DelegateAnimation <MoveAnimation> MoveBetween(this Transform transform, Transform from, Transform to, float duration = 1f, Func <float, float> easingFunction = null)
        {
            var animation = new DelegateAnimation <MoveAnimation>(() =>
                                                                  new MoveAnimation(
                                                                      transform.gameObject,
                                                                      from.position,
                                                                      to.position,
                                                                      duration,
                                                                      easingFunction,
                                                                      false));

            return(animation);
        }
Ejemplo n.º 11
0
        public void Set(Vector3 _from, Vector3 _to, float _time, GameMath.AnimateMode _mode, GameMath.Curves _curve)
        {
            from  = _from;
            to    = _to;
            speed = 1 / ((_time != 0) ? _time : Mathf.Epsilon);
            switch (_curve)
            {
            case GameMath.Curves.Bounce: curve = GameMath.Bounce; break;

            case GameMath.Curves.Log: curve = GameMath.Log01; break;

            case GameMath.Curves.Sigmoid: curve = GameMath.Sigmoid01; break;

            case GameMath.Curves.SteepSigmoid: curve = GameMath.SteepSigmoid01; break;

            case GameMath.Curves.ZigZag: curve = GameMath.ZigZag01; break;

            case GameMath.Curves.Exp: curve = GameMath.ExtremeExp01; break;
            }
            switch (_mode)
            {
            case GameMath.AnimateMode.position: animation = AnimatePosition; break;

            case GameMath.AnimateMode.localPosition: animation = AnimateLocalPosition; break;

            case GameMath.AnimateMode.eulerAngles: animation = AnimateEulerAngles; break;

            case GameMath.AnimateMode.localEulerAngles: animation = AnimateLocalEulerAngles; break;

            case GameMath.AnimateMode.rotation: animation = AnimateRotation; break;

            case GameMath.AnimateMode.localRotation: animation = AnimateLocalRotation; break;

            case GameMath.AnimateMode.localScale: animation = AnimateLocalScale; break;
            }
            StartCoroutine(PlayAnimation());
        }
Ejemplo n.º 12
0
 // Use this for initialization
 void Start()
 {
     _delegateAnimation = new DelegateAnimation(PlayFinish1);
     _delegateAnimation.PlayAnimation();
 }