Author Topic: Two Bugs/Issues in NGUI 3.0.8f7  (Read 7056 times)

kromenak

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Two Bugs/Issues in NGUI 3.0.8f7
« on: January 15, 2014, 04:39:15 PM »
Not sure if this is the place for bug reports, but I didn't see any other place, so here it is!

First off, I got this a couple times in the editor while switching between panels.  Not sure if it is a problem with the way I'm doing something, but it had worked previously with NGUI 2.x:
  1. NullReferenceException
  2. UnityEngine.Material..ctor (UnityEngine.Shader shader)
  3. UIDrawCall.CreateMaterial () (at Assets/Foundation/NGUI/Scripts/Internal/UIDrawCall.cs:310)
  4. UIDrawCall.RebuildMaterial () (at Assets/Foundation/NGUI/Scripts/Internal/UIDrawCall.cs:325)
  5. UIDrawCall.UpdateMaterials () (at Assets/Foundation/NGUI/Scripts/Internal/UIDrawCall.cs:347)
  6. UIDrawCall.Set (.BetterList`1 verts, .BetterList`1 norms, .BetterList`1 tans, .BetterList`1 uvs, .BetterList`1 cols) (at Assets/Foundation/NGUI/Scripts/Internal/UIDrawCall.cs:470)
  7. UIPanel.SubmitDrawCall (.UIDrawCall dc) (at Assets/Foundation/NGUI/Scripts/UI/UIPanel.cs:1042)
  8. UIPanel.FillAllDrawCalls () (at Assets/Foundation/NGUI/Scripts/UI/UIPanel.cs:999)
  9. UIPanel.UpdateSelf () (at Assets/Foundation/NGUI/Scripts/UI/UIPanel.cs:939)
  10. UIPanel.LateUpdate () (at Assets/Foundation/NGUI/Scripts/UI/UIPanel.cs:893)

Second, I started getting an issue from time to time on Android, though not sure if it's platform-specific.  It wasn't happening in the editor though.  When a panel is not on screen, I disable it or enable it using this code:

  1. public static void SetPanelsEnabled(GameObject parent, bool enabled)
  2.         {
  3.                 if(parent == null) { return; }
  4.                
  5.                 // Enable/disable panel elements.
  6.                 UIPanel[] panels = parent.GetComponentsInChildren<UIPanel>(true);
  7.                 for(int i = 0; i < panels.Length; ++i)
  8.                 {
  9.                         panels[i].enabled = enabled;
  10.                 }
  11.         }
  12.  

However, I get this error on device if I use that code:
  1. I/Unity   (28837): NullReferenceException: Object reference not set to an instance of an object
  2. I/Unity   (28837):   at UIPanel.FindDrawCall (.UIWidget w) [0x00098] in /Projects/TicTactics/Assets/Foundation/NGUI/Scripts/UI/UIPanel.cs:1301
  3. I/Unity   (28837):   at UIPanel.UpdateWidgets () [0x0010b] in /Projects/TicTactics/Assets/Foundation/NGUI/Scripts/UI/UIPanel.cs:1269
  4. I/Unity   (28837):   at UIPanel.UpdateSelf () [0x00017] in /Projects/TicTactics/Assets/Foundation/NGUI/Scripts/UI/UIPanel.cs:934
  5. I/Unity   (28837):   at UIPanel.LateUpdate () [0x00020] in /Projects/TicTactics/Assets/Foundation/NGUI/Scripts/UI/UIPanel.cs:893
  6.  

When I removed the calls to enable/disable the panels when showing/hiding the screens, this error no longer showed up.

Not sure if that's helpful, but hopefully it can give you some clues.

kromenak

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: Two Bugs/Issues in NGUI 3.0.8f7
« Reply #1 on: January 15, 2014, 04:49:53 PM »
To follow up on that first issue, it seems that I had some UITextures in my panel that were using the "Unlit/Transparent" shader that comes with Unity.  When I switched this to the "Unlit/Transparent Colored" shader that comes with NGUI, everything seems to be working...maybe at runtime, the Unity shader can't be loaded correctly for some reason?

astrowonderpop

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Two Bugs/Issues in NGUI 3.0.8f7
« Reply #2 on: January 29, 2014, 06:07:26 AM »
I encountered this on my Mac with NGUI 3.0.9 f4.
I had a UITexture that wouldn't render (it displayed as a big pink square).
It said there was an error occurring in UIPanel.cs, UpdateSelf, line 959 or so.
So I put in a null check at that part and that seemed to fix it.
My UITexture appeared back on the screen and that awful pink rectangle was gone.

Note the inclusion of dc != null :
  1. for (int i = 0; i < drawCalls.size; )
  2.                         {
  3.                                 UIDrawCall dc = drawCalls.buffer[i];
  4.  
  5.                                 if (dc!=null && dc.isDirty && !FillDrawCall(dc))
  6.                                 {
  7.  

I also had to update UIPanel.cs UpdateDrawCalls, which also needed a null check. Had to stick in if dc == null continue in the loop.
  1. for (int i = 0; i < drawCalls.size; ++i)
  2.                 {
  3.                         UIDrawCall dc = drawCalls.buffer[i];
  4.  
  5.                         if (dc == null)
  6.                                 continue;
  7.  
  8.                         Transform t = dc.cachedTransform;
  9.                         t.position = pos;
  10.                         t.rotation = rot;
  11.                         t.localScale = scale;
  12.  
« Last Edit: January 30, 2014, 11:29:41 PM by astrowonderpop »