LeftRect = new Rect(0, 0, Screen.width / 2, Screen.height);
RightRect = new Rect(Screen.width / 2, 0, Screen.width / 2, Screen.height);
The “LeftRect” creates an image on the left side of the screen and “RightRect” creates an image on the right side of the screen. And how can I get the information, that one of that is touched on my Android device? I don’t know, how to use “Hittest”.
foreach (Touch touch in Input.touches)
{
if (touch.phase == TouchPhase.Began)
{
Ray ray = Camera.main.ScreenPointToRay (touch.position);
RaycastHit hit = new RaycastHit();
if (Physics.Raycast (ray,out hit,1000.0f))
{
if(hit.collider.gameObject == this.gameObject)
{
Debug.LogWarning(hit.transform.name);
}
}
}
}
don´t forget to assign a collider to your gameobject. Also you need a Camera which has the tag “MainCamera”.