Unity - Button causes lag on a mobile device
Hey guys,
I have a weird problem. I created an UI with the inbuilt UI-System. The problem is, whenever I hit a button, and it doesnt matter which button it is, for the first time, I get a majot lag. It is visible, because it stops my ongoing animation on that screen, I tried out the profiler, to check what causes it. The funny thing is, that it seems to be the EventSystem. I don't even need to trigger the button. Like holding it and releasing it not being on top of it, causes the same. It is basicly the moment the button triggers its own OnPressed().
I have a soluton in my mind, like simulating a click trough script right when the scene is loaded. But this is so wrong :D.
Thanks in advance, Ibrahim
Answer by tojynick · Jan 08, 2021 at 10:44 AM
I had the exact same problem, but I fixed it. Just use IL2CPP instead of Mono when you build. It makes the game go much smoother and removes this stupid "first press lag" :)