system
1
-suppose I have 40input axes, 70fps, each axis has a string of length 10, unity will compare (407010)28000 chars for input per second?
If so, it seems to be a waste of a lot of resources? Is it possible to change the input manager script?(e.g. change it to compare int instead) Or is it possible to ignore the input manager, and implement my own?
-why unity uses Strings for method name in SendMessage function? Suppose I have very long function names and need to SendMessage quite often, wouldn’t it slow the performance a lot? Should I avoid using this function? Any special trick to boost performance if I want similar functionality as SendMessage?
Waz
2
The Input manager probably uses a hashtable, or even a perfect hashing function, so it’s probably not as bad as you guess. But yes, you can write your own. I’ve seen at least one posted on the forums. Unfortunately, there is no way to look up a KeyCode in advance.
SendMessage has to use strings, since it sends messages without knowing anything about the types of the components in the receiver. Yes, you should avoid using it too often. If you know the type of the component you are trying to invoke a function on, cache a GetComponent result in Awake and then call the function directly.