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
AppendDeepToString(StringBuilder, IEnumerator, string, Func<Object, Object>) void
Each element returned by `enumerator` is appended to `text`.
static
AppendDescription(StringBuilder, IHasDescription, string, bool) StringBuilder
Appends "Null" if `hasDescription` is null. Otherwise calls Animancer.IHasDescription.AppendDescription(System.Text.StringBuilder,System.String).
static
AppendDescription<T>(StringBuilder, T, string, bool) StringBuilder
Appends "Null" if `maybeHasDescription` is null. Otherwise calls Animancer.IHasDescription.AppendDescription(System.Text.StringBuilder,System.String).
static
AppendField<T>(StringBuilder, string, string, T, string, bool) StringBuilder
Appends {prefix}{name}: {value}.
static
ApplyChildWeight(Playable, AnimancerNode) void
Applies the `child`'s current Animancer.AnimancerNode.Weight.
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
Connect<TParent, TChild>(PlayableGraph, TParent, TChild, int, float) void
Calls UnityEngine.Playables.PlayableGraph.Connect``2(``0,System.Int32,``1,System.Int32) using output 0 from the `child` and UnityEngine.Playables.PlayableExtensions.SetInputWeight``1(``0,System.Int32,System.Single).
static
ContentsAreEqual<T>(IList<T>, IList<T>) bool
Are both lists the same size with the same items in the same order?
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, AnimancerGraph) 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
DeepToString(IEnumerable, Func<Object, Object>) string
Returns a string containing the value of each element in `collection` (each on a new line).
static
DeepToString(IEnumerable, string, Func<Object, Object>) string
Returns a string containing the value of each element in `collection`.
static
DeepToString(IEnumerator, Func<Object, Object>) string
Returns a string containing the value of each element in `enumerator` (each on a new line).
static
DeepToString(IEnumerator, string, Func<Object, Object>) string
Returns a string containing the value of each element in `enumerator`.
static
FindOutput(PlayableGraph, Playable) PlayableOutput
Returns the output connected to the `sourcePlayable` (if any).
static
FindRoot(GameObject) Transform
[Editor-Only] Takes a `gameObject` and returns the root UnityEngine.Transform of the character it is part of.
static
FindRoot(Object) Transform
[Editor-Only] Calls Animancer.AnimancerUtilities.FindRoot(UnityEngine.GameObject) if the specified `obj` is a UnityEngine.GameObject or UnityEngine.Component.
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
Get<TKey, TValue>(Dictionary<TKey, TValue>, TKey) TValue
Returns the value registered in the `dictionary` using the `key`.
static
GetDescription(IHasDescription, string) string
Calls Animancer.IHasDescription.AppendDescription(System.Text.StringBuilder,System.String) with a pooled System.Text.StringBuilder.
static
GetLastKey(AnimancerStateDictionary, Object) Object
If a state is registered with the `key`, this method gets it and repeats that check then returns the last state found.
static
GetParameterValue(Animator, AnimatorControllerParameter) Object
Gets the value of the `parameter` in the `animator`.
static
GetRootKey(Object) Object
If the `key` is an Animancer.AnimancerState, this method gets its Animancer.AnimancerState.Key and repeats that check until it finds another kind of key, which it returns.
static
GetUnsupportedMessage<T>(T) string
Returns a string stating that the `value` is unsupported.
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
InitializeCleanDictionary<TKey, TValue>(Dictionary<TKey, TValue>) bool
Creates a new dictionary and returns true if it was null or calls Animancer.AnimancerUtilities.RemoveDestroyedObjects``2(System.Collections.Generic.Dictionary{``0,``1}) and returns false if it wasn't.
static
InsertAt<T>(T[], int, T) void
Resizes the `array` to be 1 larger and inserts the `item` at the specified `index`.
static
IsInList(IUpdatable) bool
Is the `updatable` currently in a list?
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 its Animancer.AnimancerNodeBase.Playable valid?
static
IsValid(ITransition) bool
Returns the Animancer.ITransitionDetailed.IsValid with support for Animancer.IWrapper.
static
IsValid(ITransitionDetailed) bool
Is the `transition` not null and Animancer.ITransitionDetailed.IsValid?
static
NullIsEmpty<T>(T[]) T[]
Returns the `array`, or System.Array.Empty``1 if it was null.
static
ReleaseToString(StringBuilder) string
[Animancer Extension] Calls System.Text.StringBuilder.ToString and Animancer.StringBuilderPool.Release(System.Text.StringBuilder).
static
RemoveAt<T>(T[], int) void
Removes the item at the specified `index` and resizes the `array` to be 1 smaller.
static
RemoveDestroyedObjects<TKey, TValue>(Dictionary<TKey, TValue>) void
Removes any items from the `dictionary` that use destroyed objects as their key.
static
RemovePlayable(Playable, bool) void
[Pro-Only] Reconnects the input of the specified `playable` to its output.
static
Set<TKey, TValue>(Dictionary<TKey, TValue>, TKey, TValue) void
Registers the `value` in the `dictionary` using the `key`, replacing any previous value.
static
SetChildWeight(Playable, AnimancerState, float) void
Sets and applies the `child`'s Animancer.AnimancerNode.Weight and Animancer.AnimancerState.IsActive.
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. Otherwise, it returns false and the array us unchanged.
static
StartsWithNewLine(string) bool
Does the `text` start with a new line character?
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
TryCalculateDuration(Object, float) bool
Tries to calculate the amount of time (in seconds) from the Animancer.ITransitionDetailed.NormalizedStartTime too the Animancer.AnimancerEvent.Sequence.NormalizedEndTime, including the Animancer.ITransitionDetailed.Speed
static
TryGet<T>(IList<T>, int, T) bool
If the `index` is within the `list`, this method outputs the `item` at that `index` and returns true.
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
TryGetFadeDuration(ITransition) float
Returns the Animancer.ITransition.FadeDuration or System.Single.NaN if it throws an exception.
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
TryGetGameObject(Object, GameObject) bool
[Editor-Only] Outputs the UnityEngine.GameObject assignated with the `obj` and returns true if it exists.
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
TryGetObject<T>(IList<T>, int, T) bool
If the `index` is within the `list` and that `item` is not null, this method outputs it and returns true.
static
TryGetTransform(Object, Transform) bool
If the `obj` is a UnityEngine.Component or UnityEngine.GameObject, this method outputs its `transform` and returns true.
static
TryGetWrappedObject<T>(Object, T, bool) bool
Returns the last Animancer.IWrapper.WrappedObject which is a T, including the `wrapper` itself.
static