- Home /
GUI Scripting button controls
hello i have very simple problem but i just dont know how to solve it
i have my small gui button with my texture, what i want is to display another label with texture as full screen size whenever i click my small button
i guess i must locate my function into update() function to call in each frame but i just couldnt figure it out
here s my code
public Texture storyiconleft; public Texture storyiconfullscreen;
void Start () {
}
void Update () {
}
void OnGUI() {
if(GUI.Button(new Rect(0,535,150,200),storyiconleft))
showstoryboard();
}
public void showstoryboard()
{
GUI.Label (new Rect(Screen.width + 100 , 0, 500, 600),storyiconfullscreen);
}
any quick help is appreciated
first you cant call GUI labels,buttons,etc.. out of the OnGUI() function.
Answer by sriram90 · Apr 08, 2011 at 06:25 AM
hey ,
you may just try it with GUIStyle..
public Texture storyiconleft; public GUIStyle storyiconfullscreen = new GUIStyle(); // you just drag your texture and make size change from inspector. private bool showstoryboard = false;
void OnGUI() { if(GUI.Button(new Rect(0,535,150,200),storyiconleft)) { showstoryboard = true;
}
if(showstoryboard)
{
GUI.Label (new Rect(0,0,Screen.width,Screen.height)," ",storyiconfullscreen);
}
}
try it...sure you'll get perfect answer...
this is what i have been looking for , i must work more on guistyle i guess thanx a lot