- Home /
How do i use 2 GUITexture as buttons in C#
Hi all,
I have 2 GUITexture in the inspector. I want to give them different roles on mouse click. Trying to do it since 3 hours and couldn't..
Here are my variables:
public GUITexture startToAdd;
public GUITexture startToMin;
public GUITexture exitGame;
public int givenAge;
public int givenWeight;
I want to set the givenAge to givenAge+5 by clicking on the startToAdd GUITexture in the scene.
And givenWeight to givenWeight-5 by clicking on the startToMin GUITexture in the scene.
And by clicking on exitGame GUITexture, the game exits.
I'm using C#, and couldn't solve this. I'm a newbee programmer, and i need a help on this.
Any help would be appreciated..
Thanks...
Answer by PAHeartBeat · May 28, 2013 at 11:27 AM
you have to set GUITexure x,y, height and width your self in inspector window to see it side by side or up to down or down to up. once you set you GUITexture.
Add another three empty GameObject as child of where you assigned you current script.
Now add box collider on each subobject and set it proper location on your GUITexture.
Now use RayCast on click and find the name of the object where it's hit. once you get name of the object where ray hited you can write your own logic to plus or minus your value