UnityEssentials
Small but useful tools and features for Unity
RectTransformAnimation.cs
Go to the documentation of this file.
1 using System;
2 
3 namespace UnityEngine
4 {
8  [Serializable]
10  {
14  [Tooltip("The RectTransform to animate")]
15  [SerializeField] public RectTransform rectTransformToAnimate;
19  [Tooltip("The state of the RectTransform at the start of the animation")]
20  [SerializeField] public RectTransform originRectTransform;
24  [Tooltip("The state of the RectTransform at the end of the animation")]
25  [SerializeField] public RectTransform destinationRectTransform;
26 
27  // It is mandatory to have a parameterless constructor to properly work with the SimpleAnimationsManager component in the inspector.
28  public RectTransformAnimation() : this(null, null, null) { }
29 
30  public RectTransformAnimation(RectTransform rectTransformToAnimate, RectTransform destinationRectTransform, RectTransform originRectTransform, float duration = 1f, Curve curve = Curve.EaseInOut, WrapMode wrapMode = WrapMode.Once)
31  {
32  this.rectTransformToAnimate = rectTransformToAnimate;
33  this.originRectTransform = originRectTransform;
34  this.destinationRectTransform = destinationRectTransform;
35 
36 
37  this.duration = duration;
39  this.wrapMode = wrapMode;
40  }
41 
42  public override bool Step(float deltaTime, bool inverseIfMirror = true)
43  {
44  bool endOfAnimation = base.Step(deltaTime, inverseIfMirror);
45 
47 
48  return endOfAnimation;
49  }
50 
51  public override Object GetAnimatedObject(bool displayWarningIfNotApplicable)
52  {
54  }
55  }
56 
57 }
Curve
Predefined curves for the SimpleAnimations
Allows the animation of RectTransform components.
RectTransform destinationRectTransform
The state of the RectTransform at the end of the animation
RectTransform rectTransformToAnimate
The RectTransform to animate
override bool Step(float deltaTime, bool inverseIfMirror=true)
Go forward or backwards in the animation.
RectTransform originRectTransform
The state of the RectTransform at the start of the animation
override Object GetAnimatedObject(bool displayWarningIfNotApplicable)
Returns the UnityEngine.Object animated. If not applicable, return null.
RectTransformAnimation(RectTransform rectTransformToAnimate, RectTransform destinationRectTransform, RectTransform originRectTransform, float duration=1f, Curve curve=Curve.EaseInOut, WrapMode wrapMode=WrapMode.Once)
Base class to create simple animations of any element.
WrapMode
How the animation behaves once finished. Should be executed only once? Start over?...
float duration
How much should the animation last?
AnimationCurve curve
The curve of the animation over time.
float currentAnimationCurveValue
The value of the animation at the current time. 0 means start state. 1 means end state.
WrapMode wrapMode
Determines how the animation behaves once finished. Should be executed only once? Start over?...
static AnimationCurve GetCurve(Curve curve)
Obtains the desired type of animation curve with a duration of 1 (starting on 0), the start value bei...