Is it safe StringToHash() to use in Unity?
- by Sebastian Krysmanski
I'm currently browsing through the Unity tutorials and saw that they're recommending to use Animator.StringToHash("some string") to created unique ids for animation properties (see here).
Since I'm a programmer, to me the word "hash" doesn't represents something unique. Like the Java documentation for hashValue() states:
It is not required that if two objects are unequal [...], then calling the hashCode method on each of the two objects must produce distinct integer results.
So, according to this (and my definition of "hash"), two strings may have the same hash value. (You can also argue that there are an infinite number of possible strings but only 2^32 possible int values.)
So, is there a possibility that StringToHash() will give me an id that actually belongs to another property (than the one I requested the hash for)?