AnimationCurve
Represents the variation of a value over time. AnimationCurves are typically used to animate the value of Component properties in AnimationClip, but you can use them to dynamically drive any float value.
읽는 시간 2분최근 업데이트: 한 달 전
Definition
- Type: Class
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
- Implements: IEquatable<AnimationCurve>
public class AnimationCurve : IEquatable<AnimationCurve>
Remarks
The AnimationCurve class is a core component of Unity's Animation System.
To construct a simple AnimationCurve through code, use one of the following static utility methods:
- Use AnimationCurve.EaseInOut for a curve that smoothly transitions from one value to another.
- Use AnimationCurve.Linear for a curve that linearly transitions from one value to another.
- Use AnimationCurve.Constant for a curve that holds a constant value over its duration.
To construct a complex AnimationCurve, use AnimationCurve and AnimationCurve.AddKey.
Once constructed, use an AnimationCurve to animate the following properties:
- The GameObject position, rotation, scale, or component properties in an AnimationClip.
- The properties of ParticleSystem or VisualEffect.
- The properties of your own MonoBehaviour over time.
The following example illustrates how to use an AnimationCurve to gradually change the intensity of a Light.
Examples
{code Tests/EditModeAndPlayModeTests/Animation/Assets/DocumentationExamples/AnimationCurve-class-example.cs}
Constructors
Constructor | Description |
|---|---|
| AnimationCurve() | Creates an empty animation curve. |
| AnimationCurve(UnityEngine.Keyframe[]) | Creates an animation curve from an arbitrary number of keyframes. |
Properties
Property | Description |
|---|---|
| this[] | Retrieves the key at index. (Read Only) |
| keys | All keys defined in the animation curve. |
| length | The number of keys in the curve. (Read Only) |
| postWrapMode | The behaviour of the animation after the last keyframe. |
| preWrapMode | The behaviour of the animation before the first keyframe. |
Methods
Method | Description |
|---|---|
| AddKey | Add a new key to the curve. |
| ClearKeys | Erases all KeyFrame from this instance of the AnimationCurve. |
| CopyFrom | Copies the keys and properties of the specified AnimationCurve object into this instance of the AnimationCurve class. |
| Evaluate | Evaluate the curve at |
| GetHashCode | A HashCode for the animation curve, computed using all individual Keyframe. |
| GetKeys | Get all keys defined in the AnimationCurve. |
| MoveKey | Moves the key at |
| RemoveKey | Removes a key. |
| SetKeys | Set all keys defined in the AnimationCurve. |
| SmoothTangents | Smooth the in and out tangents of the keyframe at |
Static Methods
Method | Description |
|---|---|
| Constant | Creates a constant "curve" starting at |
| EaseInOut | Creates an ease-in and out curve starting at |
| Linear | A straight Line starting at |