UnityEssentials
Small but useful tools and features for Unity
Vector3Animation.cs
Go to the documentation of this file.
1 using System;
2 
3 namespace UnityEngine
4 {
8  [Serializable]
10  {
14  [Tooltip("The animated Vector3")]
15  [NonSerialized] public Vector3 vector3ToAnimate;
19  [Tooltip("The Vector3 at the start of the animation")]
20  [SerializeField] public Vector3 originVector3;
24  [Tooltip("The Vector3 at the end of the animation")]
25  [SerializeField] public Vector3 destinationVector3;
26 
27  // It is mandatory to have a parameterless constructor to properly work with the SimpleAnimationsManager component in the inspector.
28  public Vector3Animation() : this(Vector3.zero, Vector3.zero, Vector3.zero) { }
29 
30  public Vector3Animation(Vector3 vector3ToAnimate, Vector3 destination, Vector3 origin, float duration = 1f, Curve curve = Curve.EaseInOut, WrapMode wrapMode = WrapMode.Once)
31  {
32  this.vector3ToAnimate = vector3ToAnimate;
33  this.originVector3 = origin;
34  this.destinationVector3 = destination;
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  {
53  if (displayWarningIfNotApplicable)
54  Debug.LogWarning("Trying to obtain the animated object from a Vector3Animation. This action is not supported. Access the 'vector3ToAnimate' instead.");
55  return null;
56  }
57  }
58 }
Curve
Predefined curves for the SimpleAnimations
Allows the animation of a Vector3.
Vector3 originVector3
The Vector3 at the start of the animation
Vector3 destinationVector3
The Vector3 at the end of the animation
override Object GetAnimatedObject(bool displayWarningIfNotApplicable)
Returns the UnityEngine.Object animated. If not applicable, return null.
override bool Step(float deltaTime, bool inverseIfMirror=true)
Go forward or backwards in the animation.
Vector3Animation(Vector3 vector3ToAnimate, Vector3 destination, Vector3 origin, float duration=1f, Curve curve=Curve.EaseInOut, WrapMode wrapMode=WrapMode.Once)
Vector3 vector3ToAnimate
The animated Vector3
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...