- Home /
Screen position orientation flipping
I'm trying to create a glowing orb that follows a user's finger when pressed down. It works well, but the Y axis is flipped. I figure that the screen position for the ipod is flipped from what the screen position is returned. (Top left of screen is 0, 480 for Input.MousePosition and 0, 0 for GUI.Layout). How can I write this to reflect the difference in Y values?
function OnGUI()
{
if(Input.GetButton("Select"))
{
mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y);
Debug.Log("" + Input.mousePosition);
GUI.Label (Rect(mousePos.x-64, mousePos.y-64, sizeOfImage.x, sizeOfImage.y), imageToDisplay);
}
}
Answer by matyicsapo · Aug 26, 2010 at 09:02 PM
Rect(mPos.x - (imgSize.x / 2),
(Screen.height - mPos.y) - (imgSize.y / 2),
imgSize.x, imgSize.y)
sincerely hope it works :D
Wow. I was trying to figure out some grand formula for flipping the numbers. Didn't even think to subtract the position from the Screen height. Works well though, thanks a bunch.
Your answer
Follow this Question
Related Questions
Unity iPhone: AddForce to Object after Touch 0 Answers
Adapting to iOS screen sizes ? 0 Answers
One Last GUI Question 1 Answer
How to save data on iOS? 1 Answer
How to have my mobile device screen lighting on all the time 2 Answers