Log in or register to post comments

Touch on Virtual Button in Unity3d

January 10, 2013 - 11:52pm #1


I am following Virtual Button Sample in unity3d. I want check whether the touch(user's tap on screen) is in Virtual button Area (Rectangular). I am getting user's tap coordinate through "Input.mousePosition" and also button rectangle Area from "UpdateAreaRectangle();" function. I am also havnig bit confusion of getting rectangle area of button, lets say i want to get red button's rectagle area so I am doing following.




Debug.Log("is In Red button");







SO above code is right for to get Red button Rectangle. If Yes then how can I compare these values from screen tap position that whether touch is inside of Rectangle or outside. Thanks in advance.

Hi, you can project the touch

January 11, 2013 - 2:28am #2

Hi, you can project the touch screen coordinates to a 3D point by using the Camera.ScreenPointToRay() and the Physics.Raycast() function provided by the Unity API;

you can take a look at the Videoplayback sample (also in your Vuforia sample distribution), where it shows how to achieve such effect

(i.e. the example shows how to pick a 3D rectangke to trigger video start, and it uses Raycast)



Log in or register to post comments