# Using hash

**URL:** https://discussions.unity.com/t/using-hash/715264
**Category:** Animation
**Tags:** Animation
**Created:** [September 18, 2018, 9:35pm UTC](https://discussions.unity.com/t/using-hash/715264 "2018-09-18T21:35:45Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![Baste](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/baste/32/880289_2.png) [@Baste](https://discussions.unity.com/u/Baste)
#### Post date: [September 19, 2018, 8:48am UTC](https://discussions.unity.com/t/using-hash/715264/3 "2018-09-19T08:48:58Z")

</div>

It’s a micro-optimization, but it also isn’t hard to use in any way, so it’s probably a gain.

I’ve set up a file that just caches all Animator hashes used in the game, which looks like:

```auto
public static class AnimatorNames {
    public static int Attack = Animator.StringToHash("Attack");
    public static int Idle = Animator.StringToHash("Idle");
    //etc
}

```

Which means that instead of doing `myAnimator.SetTrigger("Attack");`, I do `myAnimator.SetTrigger(AnimatorNames.Attack);`.

This has the added benefit of having a centralized place where all strings used are listed, meaning that if you’re looking at an AnimatorController and are wondering where it’s triggers and bools are used, you have a single place to check.[/Code]

---

_[View the full topic](https://discussions.unity.com/t/using-hash/715264)._
