Author Topic: nullreference in UIDrawCall  (Read 3061 times)

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
nullreference in UIDrawCall
« on: February 14, 2014, 08:46:15 AM »
I got a crash report from a tester that points to a null reference error in UIDrawCall.ClearAll(). Maybe you could put a if dc!=null or dc.gameobject!=null statement there?

02-14 13:56:36.859: I/Unity(8856): NullReferenceException
02-14 13:56:36.859: I/Unity(8856):   at UnityEngine.Component.get_gameObject () [0x00000] in <filename unknown>:0
02-14 13:56:36.859: I/Unity(8856):   at UIDrawCall.ClearAll () [0x0002c] in C:\Users\Public\Documents\Unity Projects\WordMonsters\Assets\NGUI\Scripts\Internal\UIDrawCall.cs:664
02-14 13:56:36.859: I/Unity(8856):   at UIDrawCall.ReleaseAll () [0x00000] in C:\Users\Public\Documents\Unity Projects\WordMonsters\Assets\NGUI\Scripts\Internal\UIDrawCall.cs:676
02-14 13:56:36.859: I/Unity(8856):   at UIPanel.OnDisable () [0x00062] in C:\Users\Public\Documents\Unity Projects\WordMonsters\Assets\NGUI\Scripts\UI\UIPanel.cs:728

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: nullreference in UIDrawCall
« Reply #1 on: February 15, 2014, 01:01:16 AM »
It's already there.
  1.         static public void ClearAll ()
  2.         {
  3.                 bool playing = Application.isPlaying;
  4.  
  5.                 for (int i = mActiveList.size; i > 0; )
  6.                 {
  7.                         UIDrawCall dc = mActiveList[--i];
  8.  
  9.                         if (dc)
  10.                         {
  11.                                 if (playing) NGUITools.SetActive(dc.gameObject, false);
  12.                                 else NGUITools.DestroyImmediate(dc.gameObject);
  13.                         }
  14.                 }
  15.                 mActiveList.Clear();
  16.         }