Hello guys,
For our game ive made a game manager script in which we can use the unity editor to do our level design. (wave based shooter).
Before each wave i would like to be able to show an OnGUI element such as tutorials or story conversations.
So ive made another script called conversations which works exactly like my waves system (spawn/show one, once its finished open the next one).
The problem is that i want to call the OnGUI for each separate conversation. This is not allowed and i have to call the activeConversation.Update(). Obviously this is not showing anything.
Is there any possibility of showing the OnGUI for each element in my array?
You just need to access the GUI element and swap out it’s texture/text; for example
var myGUITexture = gameObject.GetComponent(GUITexture);
myGUITexture.texture = levelTextures[currentLevel];
for example
EDIT:
ok, well, if you really want to toggle the OnGUI function from objects in an array, just add a boolean to turn it on and off:
on the GUI Elements script:
var showThisGUI = false;
function OnGUI(){
if(showThisGUI){
//ALL the code goes in here
}
}
then just access the appropriate element in the array (and remember to turn all the others off):
if(showConversation){
for(var i=0;i < GuiElements.length; i++)
{
var temp = GuiElements*.GetComponent(GUIScript);*
if(i+1 == level)
temp.showThisGUI = true;
else
temp.showThisGUI = false;
}
Eventually my script was not working due to removing the monobehaviour from my class. Therefore the OnGUI function was not fireing. Thanks for the additional options to solve the issue Seth!