Author Topic: UIPanel error  (Read 4131 times)

technoir

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 1
  • Posts: 27
    • View Profile
UIPanel error
« on: August 29, 2014, 05:26:58 PM »
Hi,

I have a scene with a 2D UIRoot which takes care of the main game. I also have a Scoreboard and another item menu that I would like to switch to on  a button press. I have configured this so that each one of these has a 2D UIRoot with their own Layer. So for instance, the main game layer is 'NGUI', the Scoreboard is 'Scoreboard', and so on.  I only have the one camera however, which is in the main game UIRoot. To switch to the different menus I change the culling mask on the camera and also the EventMask on the UIcamera component . The layers are switching fine and events are working. Would this be the correct way to do this kind of switching?

However I am getting an error which occurs even when the game is not running.

The hierarchy of the menu UIRoots is as follows;

UIRoot
> Panel
>>Background
>>> Other object...

Any help would be great - Thanks
(Using NGUI 3.7.0)

The error is:

  1. NullReferenceException: Object reference not set to an instance of an object
  2. UIPanel.get_worldCorners () (at Assets/NGUI/Scripts/UI/UIPanel.cs:598)
  3. UIPanelInspector.OnSceneGUI () (at Assets/NGUI/Scripts/Editor/UIPanelInspector.cs:82)
  4. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
  5. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
  6. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
  7. System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
  8. UnityEditor.SceneView.CallOnSceneGUI () (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/SceneView/SceneView.cs:1688)
  9. UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/SceneView/SceneView.cs:1093)
  10. UnityEditor.SceneView.OnGUI () (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/SceneView/SceneView.cs:970)
  11. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
  12.  
  13.  

Yukichu

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 8
  • Posts: 101
    • View Profile
Re: UIPanel error
« Reply #1 on: August 29, 2014, 06:16:59 PM »
Uh, just disable the gameobjects when you don't need them.

If you need to still send messages to objects when they aren't seen, then set the panel alpha to 0 and/or disable it and have a script recursively disable all the colliders.

technoir

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 1
  • Posts: 27
    • View Profile
Re: UIPanel error
« Reply #2 on: September 04, 2014, 09:32:30 PM »
That works great - Thanks

Would this be the best practice then for creating menus and separate areas in NGUI (apart from having a separate scene)?
I'm pretty new to NGUI and want to make sure I get into the habit of structuring things the way they were designed :)

Cheers

Yukichu

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 8
  • Posts: 101
    • View Profile
Re: UIPanel error
« Reply #3 on: September 05, 2014, 06:29:30 AM »
Hrm... we need a 'best practices FAQ' or something, because I honestly don't know.