Hi! So my current GUI is getting scrapped, and I'm sure there's a better way to build one.
Might just skip to CLARIFICATION on the bottom to get an idea of the key problem.the current system has a set 3 windows (menu, selection, detail) and I want to allow infinite windows, opening as needed.
Currently, the awkward system is:
there are prefab buttons for the three different windows. they each reference a guimanager, menuType (for if its menu,selection,or detail), and id (for listing the buttons purpose, or specific object id it refers to, etc).
OnClick(), it calls gui.manager.Pick(menuType, id)
for example, we click a button with menuButton,gamehelp. it sends that to guimanager, who then sends "gamehelp" to the menu case statement, which then determines gamehelp should run the connected script function, this.GetComponent<GameHelp>().PickMenu();
that then, according to the gamehelp script, populates the middle "Selection" window with buttons.
say we click "quickstart" button, it sends SelectionButton,quickstart to GUImanager, which then jumps to the selection button case statement (so any click on a button on the middle window comes here), then in that case statement it says this.GetComponent<GameHelp>().PickSelection(selectionName);
pick selection then, in yet another case statement, takes the selection (quickstart) and draws that info in the details window.
it's the same process for the detail clicks.
so yeah, this seems all sorts of loopy. Ideally, I can just create menu scripts and when i make a new window, attach the relevant script, then when any buttons in that window are clicked, it sends a notice and id's which button/thing was clicked to the target script specified, and if it cant find it it makes it.
For example, i click gamehelp button in the base window. it looks for a gamehelp script, cant find one, so it makes a new gamehelp window w/ script, and fills with buttons like quickstart and tutorialOnThing. Clicking on one of those buttons looks for helpDetail window, it doesnt exist so it makes one and populates it. If i were to click a different gamehelp button, it'd find the existing gamedetail window and repolulate it. by the same token, a button could close it's own window and send the relevant data to another (still open) window.
Is this still backwards? am I on the right track? how do you do this sort of thing?
EDIT: ClarificationGonna try to describe what I want in the most basic terms.
a mainmenu script starts. it creates a window and procedurally adds some buttons: help, quit, review, and a list of 1-8 names. when it adds the button, it passes on the information of what method in mainmenu.cs it should call. In the case of the name buttons, it also passes on a specific indicator as to what name is referred to. For example, AddButton("Guy 1", NameDetails, "n1") with NameDetails being the method, and n1 being the data it should send back when it's pressed.
the Guy 1 button is pressed, and the event listener picks it up, running mainmenu.NameDetails(n1).
I figure AddButton(string name,
method) would take that data, make the button, and do the whole UIEventListener.Get(button).onClick += method;
though I'm not sure how to transfer a method to AddButton, or how to make it set the "n1" data to that specific button so when method is called, it sends the "n1" parameter.