Creating custom ActionClips if you so require is very easy. Following are a few steps to consider.
Here is the basic template for creating any type of ActorActionClip. The same applies to DirectorActionClip.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
using Slate.ActionClips; [Category("My Category")] public class MyClip : ActorActionClip{ //This is displayed within the clip in the editor public override string info{ get {return "This is my awesome clip";} } //The length of the clip. Both get/set are optional. No override means the clip won't be scaleable. public override float length{ get {} set {} } //The blend in time. Both get/set are optional. No override means no blending in public override float blendIn{ get {} set {} } //The blend out time. Both get/set are optional. No override means no blending out public override float blendOut{ get {} set {} } //Called once when the cutscene initialize. Return true if init was successful, or false if not protected override bool OnInitialize(){} //Called in forward sampling when the clip is entered protected override void OnEnter(){} //Called per frame while the clip is updating. Time is the local time within the clip. //So a time of 0 means the start of the clip. protected override void OnUpdate(float time, float previousTime){} //Called in forwards sampling when the clip exits protected override void OnExit(){} //Called in backwards sampling when the clip is entered. protected override void OnReverseEnter(){} //Called in backwards sampling when the clip exits. protected override void OnReverse(){} } |
Some of the important inherited members include:
1 2 3 4 5 6 7 8 9 10 11 12 |
//The target actor public GameObject actor{get;} //The root cutscene as an IDirector interface. public IDirector root{get;} //The parent track of the clip as an IDirectable interface. public IDirectable parent{get;} //The final clip weight at local clip time. //The return value depends on the current blendIn and blendOut properties of the clip. public float GetClipWeight(float time); |
Any field or property of the animation-supported types can be turned into an [AnimatableParameter] with a single attribute. Simply add the [AnimatableParameter] attribute on top of your field/property and it will be animatable that easy! As such you will get a mini DopeSheet on top of the clip, as well as animation curves in its inspector for those parameters. Here is an example of a clip that will log an animated float parameter “number”:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
using Slate.ActionClips; [Category("My Category")] public class MyClip : ActorActionClip{ [SerializeField, HideInInspector] private float _length; [AnimatableParameter] public float number; public override float length{ get {return _length;} set {_length = value;} } protected override void OnUpdate(float time, float previousTime){ UnityEngine.Debug.Log(number); } } |
The supported animatable types currently are: bool, int, float, Vector2, Vector3, Vector4, Quaternion, Color, Rect, and Bounds.
You can add [ShowTrajectory] attribute over any Vector3 [AnimatableParemeter] to have an editable motion path show in the scene view for that parameter.
You can add [PositionHandle] attribute over any Vector3 [AnimatableParameter] to be able to adjust the value of that parameter in the scene view through a position gizmo handle. This attribute can optionally be provided the name of a Vectror3 rotation property/field so that the position handle is rotated accordingly.
You can add [RotationHandle] attribute over any Vector3 [AnimatableParameter] to be able to adjust the value of that parameter in the scene view through a rotation gizmo handle. This attribute requires to be provided the name of a position field/property so that the rotation handle is shown at that position. For Example.
1 2 3 4 5 6 |
[AnimatableParameter, PositionHandle(nameof(rotation))] public Vector3 position; [AnimatableParameter, RotationHandle(nameof(position))] public Vector3 rotation; |
© Paradox Notion 2016-2024. All rights reserved.