Architecture for complex menu systems with UI

Hi!

I’m having some trouble choosing the best way to assemble my menus with Unity 4.6 UI.
I wanted to create a complex menu full of different windows, sub windows info boxes etc…something like “football manager” or the original x-com series.

What kind of methodology should I use since I can’t develop a architecture with out knowing what is possible with UI?

Normally I prefer to create a class and methods to handle all the layout in GUI using Screen proprieties and instantiate and destroy methods. But I notice some people are using SetActive(true false) that I still find hard to use since once “false” I can’t “Find” or “FindWithTag” also some users are moving their panels out of the canvas.

I think a nice way would be to use multiple Canvas's, and place in World Space rather than Overlay Mode.. You could have you menu then Zoom / Flip rotate into view etc.

"What's best" questions should be posted on the forums, since that involves discussion and opinion, making it unsuitable for UnityAnswers, which is focussed on objective answers to specific questions.

1 Answer

1

This is really a forum question. But here are some thoughts anyway. Remember you don’t have to use any method on its own, combine as appropriate.

Instantiate and destroy prefabs

This method works well. It is heavy on the coding. It is also heavy on the GC. It does require a few tricks to instantiate a prefab in the right place. You can use the resources folder to store prefabs if you want to be able to load them dynamically at runtime.

Enable and Disable

This is my preferred method. Use SetActive() to control if something is on screen or not. Much lighter on the coding and the GC. It does require you to set up most of your UI visually instead of by code. It does limit your options in terms of generating new UI. I’ve overcome the Find issue by having all of my UI elements enabled for one frame at the beginning or each scene. Or you can assign references via the inspector.

Moving in hierarchy

Expensive in terms of over draw. This does make sense for tabs or other similar functionality where you want to switch between windows.