- Home /
How to run String To Hash at compile time?
I'm storing hash string integer (generated by function Animator.StringToHash) as constant for global use.
public static readonly int PARAM_MOVE = Animator.StringToHash("move");
But I want to generate hash at compile time, so that I can do this
public const int PARAM_MOVE = CompileTime_StringToHash("move");
So how to run String To Hash at compile time? Thanks.
Answer by NathanJSmith · May 18, 2018 at 04:20 AM
After re-think, I figure I can't do this. I think the way around is:
Step 1: Run Animator.StringToHash("move")
and write down the hash number in paper.
Step 2: hard code public const int PARAM_MOVE = -281135240;
Or just use the read-only variable like what I'm doing.
public static readonly int PARAM_MOVE = Animator.StringToHash("move");
Your answer
![](https://koobas.hobune.stream/wayback/20220612162912im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
UnityEngine.AnimatorStateInfo.nameHash' is obsolete: "Use AnimatorStateInfo.fullPathHash instead." 0 Answers
How to fix this animator is not playing an animatorcontroller? 1 Answer
Slow down an animation from Script - C# 0 Answers