Hi everybody,
Having a bit of an issue with OnGUI(). I have a boolean called Selecting which I would like to use to control when OnGUI() displays a scrollview onto my screen. So far it works ok. When I switch Selecting to true, it pops up with the arrays of buttons I want but when I click the button and change Selecting back to false, the scrollview remains, even though the functions that the button press calls successfully do their job. Is there a way to stop OnGUI() from doing this? Any help would be appreciated.
void OnGUI(){
if (Selecting) {
scrollPosition = GUI.BeginScrollView (new Rect(0,0,Screen.width+20,Screen.height),scrollPosition,new Rect(0,0,Screen.width,(Screen.height/6)*30-10),false,false);
for (int i=0; i<20; i++) {
if(Selecting){
rect = new Rect(0,i*(Screen.height/4),Screen.width,Screen.height/4);
Tub = Resources.Load("Art/Tubs/"+Flavour*, typeof(Texture)) as Texture;*
_ Icon =Resources.Load(“Art/Icons/”+Flavour*, typeof(Texture)) as Texture;_
_ GUI.DrawTexture(rect,Tub);_
_ GUI.Label (rect,Icon);_
_ if(GUI.Button (rect,Flavour,Tubs)){*_
_ SelectedFlavour = Flavour*;
print(SelectedFlavour);
FlavourSwitch();
Selecting = false;
break;
}
}
}
GUI.EndScrollView ();
}*_
* }*