Unity-Animator深入系列---fullPathHash和shortNameHash
Unity5对状态哈希做了改进,拆分成了fullPathHash和shortNameHash
测试结果:
fullPathHash支持嵌套子状态以及层,shortNameHash直接不支持路径
这是使用的测试状态机,一共三种状态
测试脚本:
public class A1 : MonoBehaviour { public Animator animator; void OnGUI() { GUILayout.Box("Layer1 fullPathHash - " + (animator.GetCurrentAnimatorStateInfo(0).fullPathHash == Animator.StringToHash("Layer1.Idle"))); GUILayout.Box("Layer1 Idle2 fullPathHash - " + (animator.GetCurrentAnimatorStateInfo(0).fullPathHash == Animator.StringToHash("Layer1.Group.Idle"))); GUILayout.Box("Layer2 fullPathHash - " + (animator.GetCurrentAnimatorStateInfo(1).fullPathHash == Animator.StringToHash("Layer2.Idle"))); GUILayout.Box("Layer1 shortNameHash - " + (animator.GetCurrentAnimatorStateInfo(0).shortNameHash == Animator.StringToHash("Idle"))); GUILayout.Box("Layer1 Idle2 shortNameHash(1) - " + (animator.GetCurrentAnimatorStateInfo(0).shortNameHash == Animator.StringToHash("Group.Idle"))); GUILayout.Box("Layer1 Idle2 shortNameHash(2) - " + (animator.GetCurrentAnimatorStateInfo(0).shortNameHash == Animator.StringToHash("Idle"))); GUILayout.Box("Layer2 shortNameHash - " + (animator.GetCurrentAnimatorStateInfo(1).shortNameHash == Animator.StringToHash("Idle"))); } }
测试结果1(Layer1.Group.Idle未跳转):
测试结果2(Layer1.Group.Idle已跳转):
最终结论:
fullPathHash支持子状态以及层,shortNameHash直接不支持路径