Author Topic: 2.33b errors  (Read 2240 times)

Game Whiz

  • Guest
2.33b errors
« on: February 16, 2013, 04:29:52 AM »
Hi,

I upgraded from 2.3 to 2.33b, noticed that you removed UIPanelAlpha, updated all my code to use UIPanel.alpha and now I'm getting hundreds of:

"NullReferenceException: Object reference not set to an instance of an object
UIWidget.get_finalAlpha () (at Assets/NGUI/Scripts/Internal/UIWidget.cs:70)
UINode.HasChanged () (at Assets/NGUI/Scripts/Internal/UINode.cs:92)
UIPanel.UpdateTransforms () (at Assets/NGUI/Scripts/UI/UIPanel.cs:734)
UIPanel.LateUpdate () (at Assets/NGUI/Scripts/UI/UIPanel.cs:944)"

Furthermore parts of my GUI started to get all messed up (sprites all get reset to the first sprite on the atlas).

Any idea on what's happening?

Alex

Game Whiz

  • Guest
Re: 2.33b errors
« Reply #1 on: February 16, 2013, 04:32:52 AM »
The error below happens the first time a scene is loaded in Unity. If I run the same scene again, the error disappears. This is happening in 4.1b4, so I'm not sure if I've bumped into a Unity bug.

Game Whiz

  • Guest
Re: 2.33b errors
« Reply #2 on: February 16, 2013, 06:05:05 AM »
In my game, I deactivate several widgets at start, since it only makes sense to show them after some events occurred.

In your finalAlpha getter (line 70 of UIWidget), you create a panel if none is available, to make sure that mPanel is not null. The problem is that CreatePanel doesn't return a panel in all cases, more specifically it doesn't return one if the widget is not enabled.

So, either I'm not disabling widgets the way NGUI is expecting me to (I use SetActive), or there's a bug in this line. For now I've made it return the widget's alpha, if mPanel is null and everything works fine.

Could you please fix this or tell me if there's another way to deactivate widgets in NGUI?


Now I'm off to see why some parts of my GUI got all messed up... hopefully it was some side effect of this bug.

Game Whiz

  • Guest
Re: 2.33b errors
« Reply #3 on: February 16, 2013, 06:18:55 AM »
Bug #2:

It seems NGUI's behaviour regarding atlases changed in a not so good way. In my game I have a reference atlas, that I point to the relevant atlas, according to the device's resolution.
Additionally I have a "Force null" behaviour, that sets the dummy atlas replacement property to null, to get rid of all texture references. Now, in 2.33b, if I set the atlas replacement property to null, it looses all sprite names (everything is set to the first sprite on the list).

Previously (i.e. 2.3), I could set the atlas replacement to null, and when I reset it to another atlas all sprites names were preserved.

Game Whiz

  • Guest
Re: 2.33b errors
« Reply #4 on: February 16, 2013, 07:05:09 AM »
Just for reference, the solution to the atlas bug is here: http://www.tasharen.com/forum/index.php?topic=3112.0

Michael, two bugs in a release... I guess you probably got the flu :P

Game Whiz

  • Guest
Re: 2.33b errors
« Reply #5 on: February 17, 2013, 06:32:35 AM »
Hi Michael,

I didn't get a direct answer from you regarding this, so the fix for my problem is:

Go to UIWidget.cs and add replace the finalAlpha property with this this:

  1.     /// <summary>
  2.     /// Widget's final alpha, after taking the panel's alpha into account.
  3.     /// </summary>
  4.  
  5.     //public float finalAlpha { get { if (mPanel == null) CreatePanel(); return mColor.a * mPanel.alpha; } }
  6.     public float finalAlpha { get { if (mPanel == null) CreatePanel(); return mPanel != null ? mColor.a * mPanel.alpha : mColor.a; } }
  7.  


This solves the issue where a widget is inactive and NGUI tries to get its final alpha.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 2.33b errors
« Reply #6 on: February 17, 2013, 06:53:32 PM »
Game Whiz, I already fixed it. You need to update.