Initial Commit
This commit is contained in:
commit
ee5c2f922d
2255 changed files with 547750 additions and 0 deletions
37
Assets/Scripts/Util/AnimatorExtensions.cs
Normal file
37
Assets/Scripts/Util/AnimatorExtensions.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace DefaultNamespace
|
||||
{
|
||||
public static class AnimatorExtensions
|
||||
{
|
||||
public static void SetFloatSafe(this Animator animator, int hash, float value)
|
||||
{
|
||||
if (animator.Exists(hash))
|
||||
{
|
||||
animator.SetFloat(hash, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetBoolSafe(this Animator animator, int hash, bool value)
|
||||
{
|
||||
if (animator.Exists(hash))
|
||||
{
|
||||
animator.SetBool(hash, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Exists(this Animator animator, int hash)
|
||||
{
|
||||
var paramCount = animator.parameterCount;
|
||||
var p = animator.parameters;
|
||||
for (var i = 0; i < paramCount; i++)
|
||||
{
|
||||
if (p[i].nameHash == hash)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue