jc_lvngstn
Topic Author
Posts: 34
Joined: 23 Sep 2013, 03:03

Any suggestions on organizing multiple panels?

06 Oct 2013, 20:13

At times, I want to display various GUIPanels. I can have them all added to the same NoesisUI root, each with its own C# script, but this gets a little cluttered. One options is I could just via code add a panel, add its script, and assign a tag to each.

I tried just creating an empty gameobject for each panel, and adding the panel and script, and then parenting the child to the parent root gameobject with the camera assigned. But the results are not visible.

So...when dealing with multiple panels that you want to turn on and off, and the possibility of adding and removing panels, any suggestions on the best approach?
Thanks,
JC
 
jc_lvngstn
Topic Author
Posts: 34
Joined: 23 Sep 2013, 03:03

Re: Any suggestions on organizing multiple panels?

07 Oct 2013, 01:44

Unless there is already something built in which I haven't found, I'm thinking I can just do this:

1. In the NoesisGUIPanel script, add a public Name property which can be set in the Unity inspector.
2. In the Awake function, have it call NoesisGUISystem.RegisterPanel(Name);
3. In the NoesisGUISystem, have a dictionary which tracks panels by their name.
4. In the NoesisGUIPanel, have a static function which returns a panel given its name. My code behind script would just call
NoesisGUIPanel inventoryPanel = NoesisGUIPanel.GetPanel("Inventory");
 
jc_lvngstn
Topic Author
Posts: 34
Joined: 23 Sep 2013, 03:03

Re: Any suggestions on organizing multiple panels?

07 Oct 2013, 14:35

This approach has worked pretty well. I believe in another post I saw it recommended that there be one single panel for the UI, and the dev would just add/remove or hide/enable elements of that ui in code.

I'm going to try that approach. Having multiple gui panels works, but probably isn't the best way to go about things.
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: Any suggestions on organizing multiple panels?

07 Oct 2013, 23:53

This approach has worked pretty well. I believe in another post I saw it recommended that there be one single panel for the UI, and the dev would just add/remove or hide/enable elements of that ui in code.

I'm going to try that approach. Having multiple gui panels works, but probably isn't the best way to go about things.
Having multiple gui panels that render to the screen is not the best approach because each NoesisGUIPanel creates its own UI Renderer, which manages among other things mouse and keyboard events, keyboard focus, etc. This can lead to a unexpected behaviour when a user interacts with your GUI.

As we suggested, the proper way to organize multiple panels is to have a single NoesisGUIPanel (when rendering to the screen) with a root container where the developer can add/remove or hide/enable elements of the UI in code.

Who is online

Users browsing this forum: Google [Bot] and 11 guests