"GUI scripting"

Hello,
I have an idea. What if there could be an easy way to control the flow of GUI data from ANY script into a single main GUI interface instead of having GUIs from multiple scripts overlap each other, or have both options available for the developer? What if there are scenarios where I would like it where if 1 GUI is running from a script, all other GUIs shut off, and I could have one GUI easily ‘dominate’ all the others, and do this without doing a whole bunch of complex coding (like using GetComponent and if statements constantly which can exponentiate in time the more scripts that run GUI)? Another words, if I have 2 different scripts that use GUI, I would have to put 2 ‘if’ statements in both scripts (1 ‘if’ statement in each script) if I don’t want any of the 2 GUIs to overlap each other. If I have 3 different scripts that use GUI, I would have to write 6 ‘if’ statements (2 in each script) if I don’t want any of the 3 GUIs to overlap each other. As you can see, individual GUI’ing can make it tedious work for the developer in the long run if the GUIs need to work together and communicate with each other. That is why I was wondering if there is an option for programming GUI into 1 main interface.

An example is that I am reading a book that displays the contents into a GUI textarea, and if a character walks up to me and talks to me, whatever they say also gets displayed into a GUI textarea, but what if WHILE I am reading a book, a character walks up to me and talks to me? The 2 GUI textareas overlap. Then, I would have to be ‘responsible’ and develop a couple of extra ‘if’ statements using GetComponent() to communicate between the two scripts in order to take care of that problem, but what if instead of having to do that, everything can easily go into a main GUI interface script? I know the answer might be, “Why DON’T you write a separate C# script that takes in data from all the other scripts and puts it into the GUI in THAT script, and only use GUI in that one script in your program?” The problem with THAT idea is, “How would the data that I send that script be responsible for not only putting data into the controls, but also creating the controls itself and what controls I wish to create? Then I would have to script ‘if’ statements for every single GUI control that’s available IF I wanted to do it THAT way (via sending special data to the script), so, that idea wouldn’t work.”, which is why I was asking about a ‘main programmable GUI’.

it would seem you missed unity moving to a new UI system with the release of 4.6.

1 Like

It’s called a manager class. It’s pretty common, and there are a bunch of different patterns you can use.

I’ll second Bored here; you should write a class that does everything you say, and then not create any GUI without going through that class.