-
- jc_lvngstn
- Posts: 34
- Joined:
Any suggestions on organizing multiple panels?
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
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
- Posts: 34
- Joined:
Re: Any suggestions on organizing multiple panels?
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
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
Code: Select all
NoesisGUIPanel inventoryPanel = NoesisGUIPanel.GetPanel("Inventory");
-
- jc_lvngstn
- Posts: 34
- Joined:
Re: Any suggestions on organizing multiple panels?
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.
I'm going to try that approach. Having multiple gui panels works, but probably isn't the best way to go about things.
-
-
sfernandez
Site Admin
- Posts: 2908
- Joined:
Re: Any suggestions on organizing multiple panels?
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.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.
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: Semrush [Bot] and 8 guests