public static Vector2Property Bind(Animator animator, Component component, string name) { var type = component.GetType(); return(new Vector2Property { x = animator.BindStreamProperty(component.transform, type, name + ".x"), y = animator.BindStreamProperty(component.transform, type, name + ".y") }); }
public static FloatProperty Bind(Animator animator, Component component, string name) { return(new FloatProperty() { value = animator.BindStreamProperty(component.transform, component.GetType(), name) }); }
public static void BindWeights(Animator animator, Component component, WeightedTransformArray weightedTransformArray, string name, out NativeArray <PropertyStreamHandle> weights) { weights = new NativeArray <PropertyStreamHandle>(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"); } }
//============================================================================================ /** * @brief Initializes the rigging integration. This is called automatically by MxM * * This function sets up native arrays of TransformStreamHandles so that the transforms * of the rig can be accessed from an animation job * * @param [PlayableGraph] a_playableGraph - the playable graph to use for the integration * @param [Animator] a_animator - a reference to the animator component * *********************************************************************************************/ public void Initialize(PlayableGraph a_playableGraph, Animator a_animator) { m_rigBuilder = GetComponentInChildren <RigBuilder>(); m_fixRigTransforms = false; m_lastTimeCached = Time.time; if (m_rigBuilder != null) { var rigLayers = m_rigBuilder.layers; m_rigs = new Rig[rigLayers.Count]; for (int i = 0; i < rigLayers.Count; ++i) { Rig rig = rigLayers[i].rig; m_rigs[i] = rig; } } m_rigStreamHandles = new NativeArray <TransformStreamHandle>(m_rigControls.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); m_rigTransformCache = new NativeArray <TransformData>(m_rigControls.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); m_rigWeightHandles = new NativeArray <PropertyStreamHandle>(m_rigs.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); m_rigWeightCache = new NativeArray <float>(m_rigs.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); for (int i = 0; i < m_rigControls.Length; ++i) { Transform controlTransform = m_rigControls[i]; m_rigStreamHandles[i] = a_animator.BindStreamTransform(controlTransform); m_rigTransformCache[i] = new TransformData() { Position = controlTransform.localPosition, Rotation = controlTransform.localRotation }; } for (int i = 0; i < m_rigs.Length; ++i) { m_rigWeightHandles[i] = a_animator.BindStreamProperty(m_rigs[i].transform, typeof(Rig), "m_Weight"); m_rigWeightCache[i] = m_rigs[i].weight; } var rigIntegrationJob = new RiggingIntegrationJob() { FixRigTransforms = m_fixRigTransforms, RigStreamHandles = m_rigStreamHandles, RigTransformCache = m_rigTransformCache, RigWeightHandles = m_rigWeightHandles, RigWeightCache = m_rigWeightCache, }; m_riggingScriptPlayable = AnimationScriptPlayable.Create(a_playableGraph, rigIntegrationJob); var output = AnimationPlayableOutput.Create(a_playableGraph, "RigIntegrationOutput", a_animator); output.SetSourcePlayable(m_riggingScriptPlayable); }
public bool Setup(Animator animator, IkChain chain, Type componentType, string weightProperty, string weightOffsetProperty, string targetOffsetProperty) { if (!chain.HasValidData()) { return(false); } // Target m_TargetOffset = chain.target.offset; if (chain.target.readFrom == TargetType.Stream) { m_EffectorStreamHandle = animator.BindStreamTransform(chain.target.target); m_UseStreamEffector = true; } else { m_EffectorSceneHandle = animator.BindSceneTransform(chain.target.target); m_UseStreamEffector = false; } // Weight if (chain.weight.useAnimatorProperty && chain.weight.propertyName != "") { m_AnimatorWeight = animator.BindStreamProperty(animator.transform, typeof(Animator), chain.weight.propertyName); m_UseAnimatorProperty = true; } m_WeightHandle = animator.BindSceneProperty(animator.transform, componentType, weightProperty); m_AnimatorWeightOffset = animator.BindSceneProperty(animator.transform, componentType, weightOffsetProperty); // Driven m_IkType = chain.driven.type; if (m_IkType == IkType.Generic) { var end = chain.driven.genericEndJoint; var mid = end.parent; var start = mid.parent; m_StartHandle = animator.BindStreamTransform(start); m_MidHandle = animator.BindStreamTransform(mid); m_EndHandle = animator.BindStreamTransform(end); } else { m_HumanLimb = chain.driven.humanoidLimb; } return(true); }
public void BindAt(int index, Animator animator, Component component, string property) { sceneHandles[index] = animator.BindSceneProperty(component.transform, component.GetType(), property); streamHandles[index] = animator.BindStreamProperty(component.transform, component.GetType(), property); }
/// <summary>Initialises the specified `index` to read a property with the specified `name`.</summary> public void InitialiseProperty(Animator animator, int index, Transform transform, Type type, string name) => _Properties[index] = animator.BindStreamProperty(transform, type, name);
public static PropertyStreamHandle BindStreamProperty(this Animator animator, Transform transform, Type type, string property) { return(animator.BindStreamProperty(transform, type, property, false)); }