- Home /
GUITexture on/off using GUILayout.Button
I'm sure this is simple for you experienced folks, but I'm a JS noob and have been scouring for a good example with no luck.
I'm trying to use GUIButtons to draw different GUITextures in the middle of the screen. Each button click draws the new GUITexture and removes the old one. Pretty simple, right? The code I have below works, but I have a long list of objects to display and think there must be a more elegant way to perform this operation. Thanks in advance for any advice!
var A : GUITexture;
var B : GUITexture;
//not sure this is necessary? Can it all go in OnGUI ?
function Start() {
A.enabled=false;
B.enabled=false;
}
function OnGUI ()
{ if (GUILayout.Button("A", GUILayout.Width(130))){
A.enabled = true;
B.enabled = false; } else if (GUILayout.Button ("frontal lobe", GUILayout.Width(130))){
B.enabled = true;
A.enabled = false;
}
Your answer
Follow this Question
Related Questions
how to make information slideshow? 0 Answers
Why won't my OnGUI() code work? 3 Answers
LaTeX Equations or Custom Fonts in Unity GUI and onGUI elements 1 Answer
Problem Displaying gameName when refreshing masterserver 0 Answers
Help with timer guitext 2 Answers