Excuse me I want to ask about GUI I have canvas where inside that canvas I have UI > button. I change the image for that button to my image like 2D sprite. Then I have function for that GUIButton but it won’t work idk why. here my code. That st is variable I declare at start and for Button, I declare
Public Texture2D Button
void OnGUI()
{
if (GUI.Button (new Rect (-1, -183, 237, 112), "ShootButton"))
{
if (CameraON == true)
{
st.SetActive(false);
CameraON = false;
}
else
{
st.SetActive(true);
CameraON = true;
}
}
}
And I have the picture to make it easy to understand.
Canvas GUI buttons and GUI.Button isn’t the same thing. Look at a tutorial about this, because this isn’t easy to explain, but i’ll try:
Canvas buttons:
You need to assign a function to a canvas button if you want it to run something, there is a list of the functions if you select the button on the inspector, there you can add functions that run after a click. There are some limitations though.
GUI.Button:
It creates a button in front of the camera at the given coordinates with the given height and width. Be careful, because [0,0] is at the edge of the screen, and you cant set it to negative variables, the string after the position is the text on the button, that it’ll display. You can change it to an image too. If it’s embedded in an if statement, then it will return true if you press the button.
The tutorials about the canvas (You should look at these at some point):
http://unity3d.com/learn/tutorials/modules/beginner/ui/ui-canvas?playlist=17111
And the scripting API about the GUI.Button:
oww I see now, so the GUI button is different from GUI canvas. i’ll check the module and try to learn it first then maybe I’ll be back here to ask again or can I just start conversation later ??
I think you could continue this thread, or even create a new one if you have a problem.
Hmm I see the forum, I see the manual and tutorial but still don’t get it. About UI > button. Maybe some1 here can give me some example to make it easy to understand. The button have target image where I change my shape of my button the name is shootbutton. Maybe any1 can help me. ?? newbie need help 