Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: zenmaster on August 13, 2014, 12:53:14 PM

Title: Multiple UI Root added on ApplicationLoad of same scene
Post by: zenmaster on August 13, 2014, 12:53:14 PM
Hi All,

We reset the game by reloading the same scene. After several resets, our screen goes grey.
We found 4 UI Roots in the game? 3 of which were the default ones. We are unable to reliably repeat this problem.

Thanks,
Kevin
Title: Re: Multiple UI Root added on ApplicationLoad of same scene
Post by: ArenMook on August 14, 2014, 07:01:25 AM
All I can suggest is make sure you have the latest version of NGUI. Beyond that I'd need more info if I was to be of any help.
Title: Re: Multiple UI Root added on ApplicationLoad of same scene
Post by: zenmaster on February 22, 2016, 10:35:35 PM
Happens with all versions of NGUI.
Never solved it but our hack worked until this week.
We named our 2d Gui camera "UI Root-init-game"

         GameObject nguiRootGO = GameObject.Find("UI Root" );
         if( nguiRootGO != null ) {
            GameObject.DestroyImmediate( nguiRootGO );
            Debug.Log( "GameObject.DestroyImmediate( nguiRootGO )" );
         }
Now the added UI Root is inactive so it doesn't find it.
Our GUI camera is not being displayed when this default UI Root is added.
If we name ours "UI Root", it removes our camera when the mysterious default "UI Root" is added.

It feels like when you add a NGUI component and it adds a UI Root for you if it didn't appear in Hierarchy?


Title: Re: Multiple UI Root added on ApplicationLoad of same scene
Post by: zenmaster on February 23, 2016, 12:33:08 AM
Put a breakpoint at NGUITools
         GameObject go = NGUITools.AddChild(null, false);
This was called from our.
  1.         void OnDestroy() {
  2.  
  3.                 Debug.Log( "Removing this stops the UI Roots from being created?" );
  4.                 liveWellModel.ChangeInContents -= changeInContentsHandler;
  5.                 /*
  6.                 foreach( FishView view in fishViews ) {
  7.                        
  8.                         // Destroy( view.gameObject );
  9.                         // forum says it takes care of unparenting too
  10.                         NGUITools.Destroy( view.gameObject  );
  11.                 } */
  12.         }
  13.  

NO UI Roots created when comment out.
Title: Re: Multiple UI Root added on ApplicationLoad of same scene
Post by: ArenMook on February 25, 2016, 09:44:14 PM
NGUI's widgets look for a panel on a parent object. If there is no panel, NGUI will create a UI for you.

Bottom line is, ensure you actually are adding the widget to something that has a panel above it.