-2
\$\begingroup\$

I have a scene in my game with a bunch of colliders2D. The game is made for android. I want to be able to click on some colliders2D and execute some functions there. So I started with OnMouseDown on the gameobjects that I was clicking. Then I had to add a rigidbody2d so this would work. Recently though, the game crashes only when playing that scene once the apk is installed in the middle of the scene. The problem is that I can't get it to crash when on the editor or playing the game remotely with Unity Remote. So I haven't got a clue what the problem is

I think it may be the fact that there are a bunch of colliders2D with onmousedown functions attached to them. I got to that conclusion after some research on the forums. Do you think this maybe causing the random crashes? I can try to attach raycast functions to this objects instead of onmousedown but it seems much more complicated code than onmousedown. Plus it will be such a pain having to go to every single function where I wrote onMouse down, I have removed those on mousedown functions by writing #if UNITY_EDITOR code #endif but the problems stays there, what can cause an only mobile crash and not on the editor, a performance issue?

\$\endgroup\$
0
\$\begingroup\$

Ok the problem was not onmousedown, but having around 10 canvas in a scene,it seems like mobiles cant handle this I solved it just by dragging all those ui objects into a canvas.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.