using Unity.Collections; namespace UnityEngine.Animations.Rigging { /// /// This class is used to create Animation C# jobs handles for WeightedTransformArray. /// public class WeightedTransformArrayBinder { /// /// Creates an array of ReadOnlyTransformHandles representing the new bindings between the Animator and the Transforms in a WeightedTransformArray. /// /// The Animator on which to bind the new handle. /// The component owning the WeightedTransformArray property. /// The WeightedTransformArray property. /// The resulting array of ReadOnlyTransformHandles. public static void BindReadOnlyTransforms(Animator animator, Component component, WeightedTransformArray weightedTransformArray, out NativeArray transforms) { transforms = new NativeArray(weightedTransformArray.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); for (int index = 0; index < weightedTransformArray.Count; ++index) { transforms[index] = ReadOnlyTransformHandle.Bind(animator, weightedTransformArray[index].transform); } } /// /// Creates an array of ReadWriteTransformHandles representing the new bindings between the Animator and the Transforms in a WeightedTransformArray. /// /// The Animator on which to bind the new handle. /// The component owning the WeightedTransformArray property. /// The WeightedTransformArray property. /// The resulting array of ReadWriteTransformHandles. public static void BindReadWriteTransforms(Animator animator, Component component, WeightedTransformArray weightedTransformArray, out NativeArray transforms) { transforms = new NativeArray(weightedTransformArray.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); for (int index = 0; index < weightedTransformArray.Count; ++index) { transforms[index] = ReadWriteTransformHandle.Bind(animator, weightedTransformArray[index].transform); } } /// /// Creates an array of PropertyStreamHandle representing the new bindings between the Animator and the weights in a WeightedTransformArray. /// /// The Animator on which to bind the new handle. /// The component owning the WeightedTransformArray property. /// The WeightedTransformArray property. /// /// public static void BindWeights(Animator animator, Component component, WeightedTransformArray weightedTransformArray, string name, out NativeArray weights) { weights = new NativeArray(weightedTransformArray.Count, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); for (int index = 0; index < weightedTransformArray.Count; ++index) { weights[index] = animator.BindStreamProperty(component.transform, component.GetType(), name + ".m_Item" + index + ".weight"); } } } }