Esempio n. 1
0
        public TransformAnimation(Transform transformToAnimate, Transform destination, Transform origin, float duration = 1f, Curve curve = Curve.EaseInOut)
        {
            this.transformToAnimate   = transformToAnimate;
            this.originTransform      = origin;
            this.destinationTransform = destination;


            this.duration = duration;
            this.curve    = SimpleAnimation.GetCurve(curve);
        }
Esempio n. 2
0
        public Vector2Animation(Vector2 vector2ToAnimate, Vector2 destination, Vector2 origin, float duration = 1f, Curve curve = Curve.EaseInOut, WrapMode wrapMode = WrapMode.Once)
        {
            this.vector2ToAnimate   = vector2ToAnimate;
            this.originVector2      = origin;
            this.destinationVector2 = destination;


            this.duration = duration;
            this.curve    = SimpleAnimation.GetCurve(curve);
            this.wrapMode = wrapMode;
        }
Esempio n. 3
0
        public ColorAnimation(Color colorToAnimate, Color destination, Color origin, float duration = 1f, Curve curve = Curve.EaseInOut, WrapMode wrapMode = WrapMode.Once)
        {
            this.colorToAnimate   = colorToAnimate;
            this.originColor      = origin;
            this.destinationColor = destination;


            this.duration = duration;
            this.curve    = SimpleAnimation.GetCurve(curve);
            this.wrapMode = wrapMode;
        }
        /// <summary>
        /// Starts playing the animation.
        /// </summary>
        /// <param name="animation">The animation that is wanted to be played.</param>
        /// <param name="resume">If the animation should continue where it was left (true) or restart (false, default).</param>
        public void Play(SimpleAnimation animation, bool resume = false)
        {
            playingAnimations.Add(animation);

            if (!resume) //TODO: If resume is true but the animation already finished, restart (or add another parameter "restartAtFinish" in the SimpleAnimation class?)
            {
                animation.Reset();
            }

            animationsToStop.Remove(animation);
        }
        /// <summary>
        /// Starts playing the animation.
        /// </summary>
        /// <param name="animation">The animation that is wanted to be played.</param>
        /// <param name="resume">If the animation should continue where it was left (true) or restart (false, default).</param>
        public void Play(SimpleAnimation animation, bool resume = false)
        {
            playingAnimations.Add(animation);

            if (!resume)
            {
                animation.Reset();
            }

            animationsToStop.Remove(animation);
        }
        public RectTransformAnimation(RectTransform rectTransformToAnimate, RectTransform destinationRectTransform, RectTransform originRectTransform, float duration = 1f, Curve curve = Curve.EaseInOut, WrapMode wrapMode = WrapMode.Once)
        {
            this.rectTransformToAnimate   = rectTransformToAnimate;
            this.originRectTransform      = originRectTransform;
            this.destinationRectTransform = destinationRectTransform;


            this.duration = duration;
            this.curve    = SimpleAnimation.GetCurve(curve);
            this.wrapMode = wrapMode;
        }
        public CameraAnimation(Camera cameraToAnimate, Camera destination, Camera origin, float duration = 1f, Curve curve = Curve.EaseInOut, WrapMode wrapMode = WrapMode.Once)
        {
            this.cameraToAnimate   = cameraToAnimate;
            this.originCamera      = origin;
            this.destinationCamera = destination;


            this.duration = duration;
            this.curve    = SimpleAnimation.GetCurve(curve);
            this.wrapMode = wrapMode;
        }
Esempio n. 8
0
        public FloatAnimation(float floatToAnimate, float destination, float origin, float duration = 1f, Curve curve = Curve.EaseInOut, WrapMode wrapMode = WrapMode.Once)
        {
            this.floatToAnimate   = floatToAnimate;
            this.originFloat      = origin;
            this.destinationFloat = destination;


            this.duration = duration;
            this.curve    = SimpleAnimation.GetCurve(curve);
            this.wrapMode = wrapMode;
        }
Esempio n. 9
0
        public IntAnimation(int intToAnimate, int destination, int origin, float duration = 1f, Curve curve = Curve.EaseInOut, WrapMode wrapMode = WrapMode.Once)
        {
            this.intToAnimate   = intToAnimate;
            this.originInt      = origin;
            this.destinationInt = destination;


            this.duration = duration;
            this.curve    = SimpleAnimation.GetCurve(curve);
            this.wrapMode = wrapMode;
        }
 /// <summary>
 /// Returns the simple animation stored in this SimpleAnimationsManager witht he same name as the given.
 /// </summary>
 /// <param name="animationName">The name of the wanted animation.</param>
 /// <returns></returns>
 public SimpleAnimation GetAnimation(string animationName)
 {
     foreach (ISimpleAnimation IAnimation in animations)
     {
         SimpleAnimation animation = (SimpleAnimation)IAnimation;
         if (string.Compare(animation.name, animationName, StringComparison.Ordinal) == 0)
         {
             return(animation);
         }
     }
     Debug.LogWarning($"Trying to find the animation with name '{animationName}' but it is not found in the 'SimpleAnimationsManager' of the GameObject {gameObject.name}", gameObject);
     return(null);
 }
        public TransformAnimation(Transform transformToAnimate, Transform destination, Transform origin, float duration = 1f, Curve curve = Curve.EaseInOut, bool move = true, bool rotate = true, bool scale = true)
        {
            this.transformToAnimate   = transformToAnimate;
            this.originTransform      = origin;
            this.destinationTransform = destination;

            this.move   = move;
            this.rotate = rotate;
            this.scale  = scale;

            this.duration = duration;
            this.curve    = SimpleAnimation.GetCurve(curve);
        }
Esempio n. 12
0
        /// <summary>
        /// Starts playing the animation.
        /// </summary>
        /// <param name="animation">The animation that is wanted to be played.</param>
        /// <param name="resume">If the animation should continue where it was left (true) or restart (false, default).</param>
        public void Play(SimpleAnimation animation, bool resume = false)
        {
            if (playingAnimations == null)
            {
                playingAnimations = new HashSet <SimpleAnimation>();
            }

            if (playingAnimations.Add(animation))
            {
                if (!resume)
                {
                    animation.Reset();
                }
            }
        }
Esempio n. 13
0
        private void ShowAnimationsArray(UnityEditor.SerializedProperty list)
        {
            UnityEditor.EditorGUI.indentLevel += 1;
            for (int i = 0; i < list.arraySize; i++)
            {
                EditorGUILayout.Space();
                using (new GUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    SerializedProperty transformProp = list.GetArrayElementAtIndex(i);

                    SimpleAnimation animation = ((SimpleAnimation)simpleAnimationsManager.animations[i]);

                    string itemName;
                    if (animation.name.IsNullOrEmpty())
                    {
                        itemName = $"Animation [{i}]";
                    }
                    else
                    {
                        itemName = $"'{animation.name}' animation [{i}]";
                    }

                    /*string animType = animation.GetType().Name;
                     * int charSize = 57;
                     * int reaminingChars = charSize - animType.Length - itemName.Length;
                     * for (int j = 0; j < reaminingChars; j++)
                     *  itemName += " ";
                     * itemName += animType;*/
                    EditorGUILayout.PropertyField(transformProp, new GUIContent(itemName), true);

                    DisplayPreview(animation);

                    EditorGUILayout.Space();
                }
                EditorGUILayout.Space();
            }
            UnityEditor.EditorGUI.indentLevel -= 1;
        }
 /// <summary>
 /// Stops playing the animation.
 /// </summary>
 /// <param name="animation">The animation that is wanted to be stopped.</param>
 public void Stop(SimpleAnimation animation)
 {
     playingAnimations.Remove(animation);
     animationsToStop.Remove(animation);
 }
 /// <summary>
 /// Sets the animation at the given progress.
 /// </summary>
 /// <param name="animation">The animation in the 'SimpleAnimationsManager' that is wanted to be updated with the new progress.</param>
 /// <param name="progress">The progress of the animation [0,1]</param>
 public void SetProgress(SimpleAnimation animation, float progress)
 {
     animation.SetProgress(progress);
 }