Author Topic: NullReferenceException after running  (Read 16191 times)

ababab5

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
NullReferenceException after running
« on: October 30, 2014, 10:22:25 AM »
Hi,

When I created a UIRoot, and I run my game, I have this error when I stop it :

  1. NullReferenceException: Object reference not set to an instance of an object
  2. UIPanel.get_worldCorners () (at Assets/NGUI/Scripts/UI/UIPanel.cs:623)
  3. UIPanelInspector.OnSceneGUI () (at Assets/NGUI/Scripts/Editor/UIPanelInspector.cs:87)
  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 ()
  9. UnityEditor.SceneView.HandleSelectionAndOnSceneGUI ()
  10. UnityEditor.SceneView.OnGUI ()
  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. UnityEditor.DockArea:OnGUI()
  13.  

Here a video of the issue :

https://www.dropbox.com/s/xkg6f41hbx40hqo/ngui%20error.mov?dl=0

What can I do ?

Thanks.
« Last Edit: October 30, 2014, 10:30:17 AM by ababab5 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NullReferenceException after running
« Reply #1 on: October 30, 2014, 01:05:05 PM »
That's something in the inspector... nothing in inspector should be trying to get panel's world corners. Not sure what you're doing there. What version of NGUI and Unity? Does it still happen if you restart Unity?

ababab5

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: NullReferenceException after running
« Reply #2 on: October 30, 2014, 01:14:31 PM »
Hi,

Unity = 4.6

NGUI = 3.7.5

Yes it happens when I restart unity.



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NullReferenceException after running
« Reply #3 on: October 30, 2014, 01:34:37 PM »
Alright, not sure about the last 4.6 beta. I suggest trying it in the latest stable 4.5 release.

juggernate

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 21
    • View Profile
Re: NullReferenceException after running
« Reply #4 on: October 30, 2014, 10:45:32 PM »
I just updated to 4.5.5p3 and I'm getting this too (not seeing on 4.5.5p2, I re-installed to check).
It seems to run/play fine in editor, but when I stop a bunch of my GUI elements lose their positioning and if I select my UI Root I get this same error.
Seeing this with NGUI 3.7.4 and 3.7.5

I also see the error below a bunch of times if I have items in my UI selected in Editor Hierarchy

  1. The targets array should not be used inside OnSceneGUI or OnPreviewGUI. Use the single target property instead.
  2. UnityEditor.DockArea:OnGUI()


ababab5

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: NullReferenceException after running
« Reply #5 on: October 31, 2014, 04:22:48 AM »
I confirm too : I tried like you asked me on Unity 4.5.5.

The same error...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NullReferenceException after running
« Reply #6 on: November 01, 2014, 05:07:14 AM »
I wonder what Unity changed there... well, change line 623 of UIPanel.cs to this:
  1. if (anchorOffset && (mCam == null || mCam.transform.parent != cachedTransform))

ababab5

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: NullReferenceException after running
« Reply #7 on: November 01, 2014, 07:12:10 AM »
Hi,

Thanks.

But I already have this :

  1. if (anchorOffset && mCam == null || mCam.transform.parent != cachedTransform)

So .. the same you asked us to add .. :(

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NullReferenceException after running
« Reply #8 on: November 01, 2014, 08:08:45 AM »
Not the same. Note the brackets.

juggernate

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 21
    • View Profile
Re: NullReferenceException after running
« Reply #9 on: November 01, 2014, 04:36:17 PM »
The extra parentheses remove the errors for me. But there are issues with anchoring in editor mode, which means I can no longer edit the anchors visually in Editor with 4.5.5p3. All of the anchored items snap to their target's center, and I no longer see the pink/purple outline of the UIRoot (I'm not sure if that outline is for the root or panel as I'm just using a single panel)

But once I hit play they seem to anchor fine and I see the pink outline again.
« Last Edit: November 02, 2014, 11:56:07 AM by juggernate »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NullReferenceException after running
« Reply #10 on: November 02, 2014, 04:05:52 AM »
Sounds like Unity broke something important. I suggest bug reporting it to them.

mishaps

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 65
    • View Profile
Re: NullReferenceException after running
« Reply #11 on: November 03, 2014, 04:34:07 AM »
yea I've experienced this issue too in unity 4.5.5p3. Downgrading back to unity 4.5.5p1 makes it go away for now.

juggernate

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 21
    • View Profile
Re: NullReferenceException after running
« Reply #12 on: November 03, 2014, 10:13:23 AM »
Submitted a bug to Unity http://fogbugz.unity3d.com/default.asp?644750_5jopc75lb108290b

I've also confirmed this on Windows with Unity 4.5.5p3.
An additional note: If the project rebuilds after a code change, or the target platform changes in the build settings, the anchoring seems to work without playing in the editor. Once play starts and then quits in editor however the anchoring is once again lost.

Aernarion

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: NullReferenceException after running
« Reply #13 on: November 03, 2014, 11:48:18 AM »
Everything is reproducible on Mac OSX 10.10 with Unity 4.5.5p3 and NGUI 3.7.5. Rebuilding the code seems to solve the issue as well, until play is pressed.

EDIT: I have been playing around and the anchors established after updating Unity to 4.5.5p3 keeps breaking and doing weird things. I need this version since it solves an issue related with Vuforia and iOS and I would not like to have to be switching from p2 to p3 to design and compile.

Did anyone get a workaround to this issue? Aren, could you give us a hand to figure out something while the bug report is managed?

Thank you very much in advance.
« Last Edit: November 03, 2014, 12:22:45 PM by Aernarion »

juggernate

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 21
    • View Profile
Re: NullReferenceException after running
« Reply #14 on: November 04, 2014, 09:24:46 AM »
I also just tested this on the latest 4.6 betas:
- 4.6.0b20 anchoring is fine
- 4.6.0b21 anchoring is broken