Author Topic: Common UI in different scenes  (Read 6941 times)

broken

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 140
    • View Profile
Common UI in different scenes
« on: June 03, 2013, 12:50:43 AM »
Hi!

I have a few scenes:
1. Main Preloader - has only 2D UI and different Game Objects like Managers
2. Lobby (Menu) - has only 2D UI and different Game Objects like Managers
3. Level Preloader - has only 2D UI and different Game Objects like Managers
4. Level - has 2D UI, 3D World and different Game Objects like Managers

All scenes except scene №1 built in Asset Bundles and dynamically loaded. At all scenes UI is different, the only thing that unites them (№1 - №4) is PopUp`s (Popup Message, Popup Error etc.).

1. How best to organize at the interface - at each scene different UIRoot or have a single UIRoot with the flag DontDestoryOnLoad and the different panels for each scene are disabled when it is needed.
2. If we use a different UIRoot for the scenes, how to make some common UI elements (Popup`s in this case).
2.a. If you mark only Popups UI with DontDestroyOnLoad, then when loading the next scene, they disappear, because the parent (UIRoot) is not marked with DontDestroyOnLoad, he would removed with child objects.
2.b. If you mark the whole UIRoot with DontDestroyOnLoad, the next scene will not only popups, but the whole UIRoot.

Thanks!

chetanmrane

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Common UI in different scenes
« Reply #1 on: June 03, 2013, 05:57:00 AM »
Hi

i am following below practices:

1. Base Scene - UIRoot - DoNotDestroy script
2. NGUI Page prefabs, with dynamic loading/unloading to UIRoot
3. Additive load popups like Confirmation pages, Levelup, Error Popups, etc.


This way, i can control runtime time memory too

broken

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 140
    • View Profile
Re: Common UI in different scenes
« Reply #2 on: June 03, 2013, 06:03:15 AM »
I think i can probably leave the scene as well as 4 I have now (just in addition to the UI there are other objects - managers, behavior, and so.), and for them to use one UIRoot with loadable panels (prefabs) for each scene. Right?

You have a one scene or multiple scenes?
« Last Edit: June 03, 2013, 06:10:14 AM by broken »

broken

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 140
    • View Profile
Re: Common UI in different scenes
« Reply #3 on: June 04, 2013, 03:13:59 AM »
Now I have 4 scenes (described above).
3 scenes relate only to the interface and the differences are only in the interface and one additional game object on the stage (the behavior of the UI). And there is a 4th scene, where in addition to its interface has a full 3D environments, lights, cameras, and so.
So I think the best way to do is to make a one scene for the interface (in which the panel will be loaded with their own behavior game objects) and for the level of one scene. So will total 2 scene.
Or leave the same four scenes, in the first scene a common interface (UIRoot) with the panels, and in the 2nd and 3rd scenes will contain only the behavior of the interface.

What is the best? Does it make sense to do a scene for game one object (different behavior of UI)?

I tend to keep to the one Main scene (with all UI, where a panels will be loaded/unloaded) and the scene levels.
« Last Edit: June 04, 2013, 03:45:11 AM by broken »

broken

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 140
    • View Profile
Re: Common UI in different scenes
« Reply #4 on: June 04, 2013, 06:32:42 AM »
Made one Main Scene in which the structure (attach1).
For each individual page design is made to Page game object, which contains the script behavior (is initially on the scene) for UI. The panel with UI is loaded through the AssetBundles.

1. Behavior scripts contains references to components that are in the loaded UI Panel in AssetBundle. (attach2)
2. Components in the loaded UI Panel contains references to script the behavior. For example - Button with UIButtonMessage script, where target is Behavior script. (attach3)

I understand that the references should be set at the runtime after downloading the AssetBundle. But how best to identify the game objects (by name, by tag, by component?) that need to reference or which have to be used in the reference? Or simply add a script behavior with the panel in the asset bundle, and load the whole Page (attach1)?

I understand that this is more a question about unity3d, but still ask to help.

Thanks!
« Last Edit: June 04, 2013, 07:48:30 AM by broken »