UnityEssentials
Small but useful tools and features for Unity
CameraAnimation.cs
Go to the documentation of this file.
1 using System;
2 
3 namespace UnityEngine
4 {
8  [Serializable]
10  {
14  [Tooltip("The Camera to animate")]
15  [SerializeField] public Camera cameraToAnimate;
19  [Tooltip("The state of the Camera at the start of the animation")]
20  [SerializeField] public Camera originCamera;
24  [Tooltip("The state of the Camera at the end of the animation")]
25  [SerializeField] public Camera destinationCamera;
26 
27 
28  // It is mandatory to have a parameterless constructor to properly work with the SimpleAnimationsManager component in the inspector.
29  public CameraAnimation() : this(null, null, null) { }
30 
31  public CameraAnimation(Camera cameraToAnimate, Camera destination, Camera origin, float duration = 1f, Curve curve = Curve.EaseInOut, WrapMode wrapMode = WrapMode.Once)
32  {
33  this.cameraToAnimate = cameraToAnimate;
34  this.originCamera = origin;
35  this.destinationCamera = destination;
36 
37 
38  this.duration = duration;
40  this.wrapMode = wrapMode;
41  }
42 
43 
44  public override bool Step(float deltaTime, bool inverseIfMirror = true)
45  {
46  bool endOfAnimation = base.Step(deltaTime, inverseIfMirror);
47 
49 
50  return endOfAnimation;
51  }
52 
53 
54  public override Object GetAnimatedObject(bool displayWarningIfNotApplicable)
55  {
56  return cameraToAnimate;
57  }
58 
59  }
60 }
Curve
Predefined curves for the SimpleAnimations
Allows the animation of Camera components.
Camera destinationCamera
The state of the Camera at the end of the animation
CameraAnimation(Camera cameraToAnimate, Camera destination, Camera origin, float duration=1f, Curve curve=Curve.EaseInOut, WrapMode wrapMode=WrapMode.Once)
override bool Step(float deltaTime, bool inverseIfMirror=true)
Go forward or backwards in the animation.
Camera originCamera
The state of the Camera at the start of the animation
override Object GetAnimatedObject(bool displayWarningIfNotApplicable)
Returns the UnityEngine.Object animated. If not applicable, return null.
Camera cameraToAnimate
The Camera to animate
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...