Summary
A system for synchronizing the
Animancer.AnimancerState.NormalizedTime
of animations within the same "group".
- Assembly
- Animancer
.dll - Namespace
- Animancer
- Base Types
-
- Object
graph BT
Type-->Base0["Object"]
Type["TimeSynchronizer<T>"]
class Type type-node
Syntax
public class TimeSynchronizer<T>
Remarks
- Store a
in a field. - Call any of the
methods before playing a new animation. - Then call any of the
methods after playing the animation.
// 1. Define your group type.
// You could use strings or ints or whatever you want, but enums are often best.
public enum AnimationGroup
{
None,
Movement,
}
[SerializeField] private AnimancerComponent _Animancer;
// 2. Store a TimeSynchronizer in a field.
private readonly TimeSynchronizer<AnimationGroup>
TimeSynchronizer = new();
public AnimancerState Play(AnimationClip clip, AnimationGroup group)
{
// 3. Call one of the StoreTime methods before playing a new animation.
TimeSynchronizer.StoreTime(_Animancer);
// 4. Play an animation.
var state = _Animancer.Play(clip);
// 5. Call one of the SyncTime methods after playing the animation.
// If the `group` was the same as the value from last time you called it,
// then the state's NormalizedTime will be set to the stored value.
TimeSynchronizer.SyncTime(state, group);
return state;
}
Type Parameters
Name | Description |
---|---|
T |
Constructors
Name | Summary |
---|---|
TimeSynchronizer |
Creates a new Animancer.TimeSynchronizer`1 . |
TimeSynchronizer |
Creates a new Animancer.TimeSynchronizer`1 . |
Properties
Name | Value | Summary |
---|---|---|
CurrentGroup | T |
The group that the current animation is in.
|
NormalizedTime | double |
The stored
Animancer.AnimancerState.NormalizedTimeD . |
State | AnimancerState |
The state which the
Animancer.TimeSynchronizer`1.NormalizedTime came from (to avoid syncing with itself). |
Synchronize |
bool |
Should synchronization be applied when the
Animancer.TimeSynchronizer`1.CurrentGroup is at its default value? |
Methods
Name | Value | Summary |
---|---|---|
StoreTime |
void |
Stores the
Animancer.AnimancerState.NormalizedTimeD of the Animancer.AnimancerLayer.CurrentState .
|
StoreTime |
void |
Stores the
Animancer.AnimancerState.NormalizedTimeD of the `state`. |
StoreTime |
void |
Sets the
Animancer.TimeSynchronizer`1.State and Animancer.TimeSynchronizer`1.NormalizedTime . |
SyncTime |
bool |
Applies the
Animancer.TimeSynchronizer`1.NormalizedTime to the Animancer.AnimancerLayer.CurrentState
if the `group` matches the Animancer.TimeSynchronizer`1.CurrentGroup .
|
SyncTime |
bool |
Applies the
Animancer.TimeSynchronizer`1.NormalizedTime to the Animancer.AnimancerLayer.CurrentState
if the `group` matches the Animancer.TimeSynchronizer`1.CurrentGroup .
|
SyncTime |
bool |
Applies the
Animancer.TimeSynchronizer`1.NormalizedTime to the `state`
if the `group` matches the Animancer.TimeSynchronizer`1.CurrentGroup .
|
SyncTime |
bool |
Applies the
Animancer.TimeSynchronizer`1.NormalizedTime to the `state`
and returns true if the `group` matches the Animancer.TimeSynchronizer`1.CurrentGroup .
|