InputBinder icon indicating copy to clipboard operation
InputBinder copied to clipboard

how are performances?

Open laurentopia opened this issue 5 years ago • 5 comments

getaxis (string) allocates a lot so i was wondering how this thing compares

laurentopia avatar May 26 '20 22:05 laurentopia

It uses GetAxis(string) internally but string is only allocated when the binding is created so it should be better than calling GetAxis(“Jump”) in every update for example.

Best to give it a try and profile it to see what the reality is though since I haven’t used this for quite some time.

RyanNielson avatar May 26 '20 23:05 RyanNielson

Thanks man, trying it nao

laurentopia avatar May 27 '20 00:05 laurentopia

so I'm reading your code, GetAxis gets called every frame like mine, it's just that you keep the string in a variable, so that means that the each frame allocation I'm getting comes from inlining "string" vs having a string variable?

laurentopia avatar May 27 '20 00:05 laurentopia

Yep, that should be the case. If you define your input name string as an constant instance variable in your component you should get similar behaviour.

Also if you haven’t yet check out the new Unity input system. You should be able to get it from the Unity package manager. It’s going to be the future standard way to do input it seems and it’s pretty cool.

RyanNielson avatar May 27 '20 10:05 RyanNielson

In my tests GetAxis("string") vs GetAxis(aString) makes no difference

laurentopia avatar May 29 '20 21:05 laurentopia