Author Topic: Multiple Scenes, Common UI  (Read 4048 times)

alan.lawrance

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Multiple Scenes, Common UI
« on: March 13, 2013, 09:58:38 PM »
New NGUI user here.  For a project with these properties:

* Multiple scenes (level based game, each level is a scene)
* Shared UI across all scenes (pause menu, HUD, etc)

I am considering settings things up in the following way:

* Create shared UI in a separate scene for easy testing, save the UIRoot (and everything below it) as a prefab
* Instantiate (via code) that prefab in each scene, and turn on/off the panels needed using NGUITools.SetActive

Does this seem like a reasonable approach?  Are there other methods that may be better?  One concern I the time it takes to load the UI, since it will happen every time a scene gets loaded.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Multiple Scenes, Common UI
« Reply #1 on: March 14, 2013, 01:14:33 AM »
If the UI is shared, why instantiate it in every scene? You can simply DontDestroyOnLoad on it after instantiating it once, and it will travel from one scene to another. If it already exists, don't instantiate a new copy.