Log in or register to post comments

GUIbutton work only with the image target

November 9, 2012 - 12:28pm #1

I want that this GUIbutton work only with the image target, an not outside the image target, how can i fix that.

_____________________________________________________________________________________________


var myObject : GameObject;

 

function Start(){

  myObject = GameObject.Find("teapot");

}

 

function Update () {

if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){

    if (guiTexture.HitTest(Input.GetTouch(0).position)){

        myObject.renderer.enabled = !myObject.renderer.enabled;

        }

    }

}

 

GUIbutton work only with the image target

November 11, 2012 - 7:17am #3

im using a GUItexture as a touch button, always in the screen, the problem is tha when i press the touch button outside the image tracker, the object stiil appear and disapear in the screen. how can i fix this script.

GUIbutton work only with the image target

November 9, 2012 - 3:56pm #2

So the teapot is rendered when the user touches the target?

Take a look at the example is this thread - https://ar.qualcomm.at/content/how-add-touch-listener-3d-object-unity

This approach uses SendMessage to fire the OnMouseDown event on the touched object, which enables you to customize the handling and isolate it to the region of the target.

Log in or register to post comments