Skip to content

Commit 3814932

Browse files
committed
fix(Util): check animator layer
1 parent 6a78298 commit 3814932

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Assets/JCSUnity/Scripts/Util/JCS_Animator.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,14 @@ public static float GetLayerWeight(Animator ator, int index)
6161
/// </summary>
6262
public static bool HasState(Animator animator, int layer, string name)
6363
{
64+
// First check if the layer exists.
65+
if (layer < 0 || animator.layerCount <= layer)
66+
return false;
67+
68+
// Convert name to hash.
6469
int stateHash = Animator.StringToHash(name);
70+
71+
// Then do the check.
6572
return animator.HasState(layer, stateHash);
6673
}
6774
}

0 commit comments

Comments
 (0)