Interactive GUI?

Hi, im making an RPG and i have some GUI Textures in it. What im wondering is how to make it so the textures can be clicked and do something. Im making a minimap and have a plus and minus texture but dont know how to make them be clickable or zoom the map in and out.

Please help,
thanks

ok, another quick question i have been trying for ages but i cant seem to script a window and button grid to open when the player presses “B” as like an inventory so the grid needs to be in front of the window.

If you want to do clicking you would create a couple functions:

function OnMouseDown()
{
     
}

This makes it so when you click your left mouse button.

function OnMouseEnter()
{
    
}

This makes it when you hover your mouse over the texture.

function OnMouseUp()
{

}

This makes it when you release your left mouse button.

OnMouseExit()
{

}

When you your mouse leaves the area of your GUI texture this happens.

With these you can create fully operating buttons.

The button syntax took me a while to figure out at first too. The key is that the Rect defines the coordinates of the button in terms of the pixel coordaintes and not the screen coordinates.

var texGraphic:Texture2D; // drag and drop your button graphic here in inspector

function OnGUI(){
if(GUI.Button( Rect(10,10,100,100) , texGraphic)){
  Debug.Log("Clicked");
}
}

As for making a minimap, you can use raycasthit to determine the screen coordinate hit, and then calculate the location of the minimap clicked on.

Zooming in and out could be as simple as switching the map images to different graphics depending on zoom distance.