NGUI - Checking if button is pressed

Hi, I’ve decided to use NGUI in my main project to reduce draw calls.
But I don’t know how I can convert my main code as it contains if(GuiTexture.HitTest)…(to check if a button has been touched)

Here’s more code :

public GUITexture MoveLeft;

void Update ()
{
				if(MoveLeft.HitTest (touch.position)) 
				{
					if(touch.phase != TouchPhase.Ended)
						moveLeft = true;
					else
						moveLeft = false;
				}
				if(MoveRight.HitTest (touch.position))
				{
					if(touch.phase != TouchPhase.Ended)
						moveRight = true;
					else
						moveRight = false;
				}
}

As you can see in this code I’m working with 2 GuiTexture buttons to check if they have been pressed. How can I do the same with NGUI buttons ? Thanks for reading.

NGUI handles UI events by sending you a callback (from UICamera), which you can set up in the inspector. Attach a button component and a collider, then set up an OnClick callback.

On the other hand, since NGUI uses Unity colliders, it’s also relatively trivial to perform your own raycast to check for clicks on NGUI buttons (see tutorial and scripting manual).