AnimancerUtilities Class

Summary

Various extension methods and utilities.
Assembly
Animancer.dll
Namespace
Animancer
Base Types
  • Object
graph BT Type-->Base0["Object"] Type["AnimancerUtilities"] class Type type-node

Syntax

public static class AnimancerUtilities

Fields

Name Constant Value Summary
IsAnimancerPro True
Is this Animancer Pro?
static

Methods

Name Value Summary
AddAnimancerComponent<T>(Animator) T
[Animancer Extension] Adds the specified type of Animancer.IAnimancerComponent, links it to the `animator`, and returns it.
static
Assert(bool, Object) void
[Assert-Conditional] Throws an UnityEngine.Assertions.AssertionException if the `condition` is false.
static
CalculateThresholdsFromAverageVelocityXZ(MixerState<Vector2>) void
[Animancer Extension] [Pro-Only] Calculates all thresholds in the `mixer` using the Animancer.AnimancerState.AverageVelocity of each state on the X and Z axes.

Note that this method requires the Root Transform Position (XZ) -> Bake Into Pose toggle to be disabled in the Import Settings of each UnityEngine.AnimationClip in the mixer.
static
Clone<T>(T) T
Creates a new T and calls Animancer.ICopyable`1.CopyFrom(`0) on it.
static
ConvertToTransformStreamHandles(IList<Transform>, Animator) NativeArray<TransformStreamHandle>
Creates a Unity.Collections.NativeArray`1 of UnityEngine.Animations.TransformStreamHandles for each of the `transforms`.
static
CopyExactArray<T>(T[], T[]) void
Ensures that the length and contents of `copyTo` match `copyFrom`.
static
CopyParameterValue(Animator, Animator, AnimatorControllerParameter) void
Copies the value of the `parameter` from `copyFrom` to `copyTo`.
static
CopyParameterValue(AnimatorControllerPlayable, AnimatorControllerPlayable, AnimatorControllerParameter) void
Copies the value of the `parameter` from `copyFrom` to `copyTo`.
static
CreateNativeReference<T>() NativeArray<T>
Creates a Unity.Collections.NativeArray`1 containing a single element so that it can be used like a reference in Unity's C# Job system which does not allow regular reference types.
static
CreateStateAndApply(ITransition, AnimancerPlayable) AnimancerState
[Animancer Extension] Calls Animancer.ITransition.CreateState and Animancer.ITransition.Apply(Animancer.AnimancerState).
static
CreateUnsupportedArgumentException<T>(T) ArgumentException
Returns an exception stating that the `value` is unsupported.
static
EditModePlay(AnimationClip, Component) void
[Editor-Conditional] Plays the specified `clip` if called in Edit Mode.
static
EditModeSampleAnimation(AnimationClip, Component, float) void
[Editor-Conditional] Applies the effects of the animation `clip` to the UnityEngine.Component.gameObject.
static
Gather(ICollection<AnimationClip>, AnimationClip) void
[Animancer Extension] Adds the `clip` to the `clips` if it wasn't there already.
static
Gather(ICollection<AnimationClip>, IEnumerable<AnimationClip>) void
[Animancer Extension] Calls Animancer.AnimancerUtilities.Gather(System.Collections.Generic.ICollection{UnityEngine.AnimationClip},UnityEngine.AnimationClip) for each of the `newClips`.
static
Gather(ICollection<AnimationClip>, IList<AnimationClip>) void
[Animancer Extension] Calls Animancer.AnimancerUtilities.Gather(System.Collections.Generic.ICollection{UnityEngine.AnimationClip},UnityEngine.AnimationClip) for each of the `newClips`.
static
GatherFromAsset(ICollection<AnimationClip>, PlayableAsset) void
[Animancer Extension] Calls Animancer.AnimancerUtilities.Gather(System.Collections.Generic.ICollection{UnityEngine.AnimationClip},UnityEngine.AnimationClip) for each clip in the `asset`.
static
GatherFromSource(ICollection<AnimationClip>, IAnimationClipSource) void
[Animancer Extension] Calls Animancer.AnimancerUtilities.Gather(System.Collections.Generic.ICollection{UnityEngine.AnimationClip},UnityEngine.AnimationClip) for each clip gathered by UnityEngine.IAnimationClipSource.GetAnimationClips(System.Collections.Generic.List{UnityEngine.AnimationClip}).
static
GatherFromSource(ICollection<AnimationClip>, IEnumerable) void
[Animancer Extension] Calls Animancer.AnimancerUtilities.GatherFromSource(System.Collections.Generic.ICollection{UnityEngine.AnimationClip},System.Object) for each item in the `source`.
static
GatherFromSource(ICollection<AnimationClip>, Object) bool
[Animancer Extension] Calls Animancer.AnimancerUtilities.Gather(System.Collections.Generic.ICollection{UnityEngine.AnimationClip},UnityEngine.AnimationClip) for each clip in the `source`, supporting both UnityEngine.IAnimationClipSource and Animancer.IAnimationClipCollection.
static
GetComponentInParentOrChildren<T>(GameObject) T
Returns the first T component on the `gameObject` or its parents or children (in that order).
static
GetComponentInParentOrChildren<T>(GameObject, T) bool
If the `component` is null, this method tries to find one on the `gameObject` or its parents or children (in that order).
static
GetOrAddAnimancerComponent<T>(Animator) T
[Animancer Extension] Returns the Animancer.IAnimancerComponent on the same UnityEngine.GameObject as the `animator` if there is one. Otherwise this method adds a new one and returns it.
static
GetParameterValue(Animator, AnimatorControllerParameter) Object
Gets the value of the `parameter` in the `animator`.
static
GetParameterValue(AnimatorControllerPlayable, AnimatorControllerParameter) Object
Gets the value of the `parameter` in the `playable`.
static
GetUnsupportedMessage<T>(T) string
Returns a string stating that the `value` is unsupported.
static
GetWrappedObject(Object) Object
Returns the Animancer.IWrapper.WrappedObject recursively.
static
HasEvent(AnimationClip, string) bool
Checks if the `clip` has an animation event with the specified `functionName`.
static
HasEvent(IAnimationClipCollection, string) bool
Checks if any UnityEngine.AnimationClip in the `source` has an animation event with the specified `functionName`.
static
IsFinite(double) bool
[Animancer Extension] Is the `value` not NaN or Infinity?
static
IsFinite(float) bool
[Animancer Extension] Is the `value` not NaN or Infinity?
static
IsFinite(Vector2) bool
[Animancer Extension] Are all components of the `value` not NaN or Infinity?
static
IsNullOrEmpty<T>(T[]) bool
[Animancer Extension] Is the `array` null or its System.Array.Length 0?
static
IsValid(AnimancerNode) bool
[Animancer Extension] Is the `node` is not null and Animancer.AnimancerNode.IsValid?
static
IsValid(ITransition) bool
Returns the Animancer.ITransitionDetailed.IsValid with support for Animancer.IWrapper.
static
IsValid(ITransitionDetailed) bool
[Animancer Extension] Is the `transition` not null and Animancer.ITransitionDetailed.IsValid?
static
RemovePlayable(Playable, bool) void
[Pro-Only] Reconnects the input of the specified `playable` to its output.
static
Round(float) float
Rounds the `value` to the nearest integer using System.MidpointRounding.AwayFromZero.
static
Round(float, float) float
Rounds the `value` to be a multiple of the `multiple` using System.MidpointRounding.AwayFromZero.
static
SetDirty(Object) void
[Editor-Conditional] Indicates that the `target` needs to be re-serialized.
static
SetLength<T>(T[], int) bool
If the `array` is null or its System.Array.Length isn't equal to the specified `length`, this method creates a new array with that `length` and returns true.
static
SetParameterValue(Animator, AnimatorControllerParameter, Object) void
Sets the `value` of the `parameter` in the `animator`.
static
SetParameterValue(AnimatorControllerPlayable, AnimatorControllerParameter, Object) void
Sets the `value` of the `parameter` in the `playable`.
static
Swap<T>(T[], int, int) void
[Animancer Extension] Swaps array[a] with array[b].
static
ToStringOrNull(Object) string
If `obj` exists, this method returns System.Object.ToString. Or if it is null, this method returns "Null". Or if it is an UnityEngine.Object that has been destroyed, this method returns "Null (ObjectType)".
static
TryGetAverageAngularSpeed(Object, float) bool
Outputs the UnityEngine.Motion.averageAngularSpeed or Animancer.IMotion.AverageAngularSpeed.
static
TryGetAverageVelocity(Object, Vector3) bool
Outputs the UnityEngine.Motion.averageSpeed or Animancer.IMotion.AverageVelocity.
static
TryGetFrameRate(Object, float) bool
Attempts to get the UnityEngine.AnimationClip.frameRate from the `clipSource` and returns true if successful. If it has multiple animations with different rates, this method returns false.
static
TryGetInvocationListNonAlloc(MulticastDelegate, Delegate[]) bool
[Assert-Only] Uses reflection to achieve the same as System.Delegate.GetInvocationList without allocating garbage every time.
  • If the delegate is null or , this method returns false and outputs null.
  • If the underlying delegate field was not found, this method returns false and outputs null.
  • If the delegate is not multicast, this method this method returns true and outputs null.
  • If the delegate is multicast, this method this method returns true and outputs its invocation list.
static
TryGetIsLooping(Object, bool) bool
Outputs the UnityEngine.Motion.isLooping or Animancer.ITransitionDetailed.IsLooping.
static
TryGetLength(Object, float) bool
Outputs the UnityEngine.AnimationClip.length or Animancer.ITransitionDetailed.MaximumDuration.
static
TryGetWrappedObject<T>(Object, T) bool
Returns the `wrapper` or first Animancer.IWrapper.WrappedObject which is a T.
static
Wrap(float, float) float
Loops the `value` so that 0 <= value < length.
static
Wrap01(float) float
Loops the `value` so that 0 <= value < 1.
static