I want to click a gui texture which has a box collider around it and I want it to trigger the shoot1 function.
Is it possible?
and could anyone tell me the script for the function of trigger “shoot1”
thank you
I want to click a gui texture which has a box collider around it and I want it to trigger the shoot1 function.
Is it possible?
and could anyone tell me the script for the function of trigger “shoot1”
thank you
GUITextures live in Viewport space. Box colliders live in World space. So you cannot have a box collider around a GUITexture. You could have a box collider track a GUITexture or have a GUITexture track a box collider. See Camera.ViewportToWorldPoint() and Camera.WorldToViewportPoint().
As for clicking on a GUITexture, you don’t need a collider. You can add this to a script on the GUITexture:
function OnMouseDown() {
Shoot1();
}
This assumes Shoot1 is in the same script as the OnMouseDown(). If it is not, see: