In my project (a Windows Streaming Web Player app), I have an object that instantiates, along with a script that allows the user to click on it to move it around and so forth. The instantiated object has a OnMouseDown() function call to perform all the stuff its supposed to do.
The problem is when the aspect ratio is set to Free Aspect, I have no problem clicking on the object. But when it's in Standalone (1024 x 768), which is the resolution I need, I can't click the object. I've used Debug.Log calls to confirm that in Free Aspect it's registering OnMouseDown clicks, and in Standalone it isn't.
The collision box is the same in both aspects, so it's not the collider's fault, I think.
The code couldn't be simpler:
What's happening here? What's the relationship between Aspect Ratio and colliders in the OnMouseDown() function?
I haven't tried to replicate your situation. But personally I use this c# code in my game:
And it's been working on PC/Mac/Web/Android and iOS in all resolutions, for button clicks and touches on the screen.
You probably want this in some singleton class called "Input" or something so you don't call it for every object in the game. Call it from some main object and then call some method on the object you clicked on.
answered Jan 31 '11 at 05:56 PM
I'm having this exact same issue. My colliders work all day in Free Aspect. The minute I make a build at 1024x768, they stop working however. I've used the same methodology/code to handle OnMouseDown events for years now. Short of writing my own raycasting, did you ever find a workaround?,I'm having this exact same issue with some colliders in my scene. They work fine in free aspect, but not in standalone.