Author Topic: Editor null reference on changing sprite atlas  (Read 3566 times)

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Editor null reference on changing sprite atlas
« on: November 11, 2013, 06:47:05 AM »
Hi, have been getting a editor error when changing the atlas of a sprite (v3.0.3):

NullReferenceException: Object reference not set to an instance of an object
NGUIEditorTools.DrawSprite (UnityEngine.Texture2D tex, Rect drawRect, .UISpriteData sprite, Color color, UnityEngine.Material mat) (at Assets/NGUI/Scripts/Editor/NGUIEditorTools.cs:703)
NGUIEditorTools.DrawSprite (UnityEngine.Texture2D tex, Rect rect, .UISpriteData sprite, Color color) (at Assets/NGUI/Scripts/Editor/NGUIEditorTools.cs:692)
UISpriteInspector.OnPreviewGUI (Rect rect, UnityEngine.GUIStyle background) (at Assets/NGUI/Scripts/Editor/UISpriteInspector.cs:117)
UnityEditor.Editor.OnInteractivePreviewGUI (Rect r, UnityEngine.GUIStyle background) (at C:/BuildAgent/work/cac08d8a5e25d4cb/Editor/MonoGenerated/Editor/EditorBindings.cs:268)
UnityEditor.Editor.DrawPreview (Rect previewPosition) (at C:/BuildAgent/work/cac08d8a5e25d4cb/Editor/Mono/Inspector/Editor.cs:303)
UnityEditor.InspectorWindow.DrawPreviewAndLabels () (at C:/BuildAgent/work/cac08d8a5e25d4cb/Editor/Mono/Inspector/InspectorWindow.cs:521)
UnityEditor.InspectorWindow.OnGUI () (at C:/BuildAgent/work/cac08d8a5e25d4cb/Editor/Mono/Inspector/InspectorWindow.cs:282)

Checking for a null UISpriteData in UISpriteInspector.OnPreviewGUI() is a work around that allows us then to modify the sprite name to something it can find in the new atlas.

ta

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Editor null reference on changing sprite atlas
« Reply #1 on: November 11, 2013, 04:18:21 PM »
The latest version is 3.0.5, not 3.0.3. Please update, and note this sticky post: http://www.tasharen.com/forum/index.php?topic=6328.0

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: Editor null reference on changing sprite atlas
« Reply #2 on: November 11, 2013, 05:03:48 PM »
last time I upgraded it took me 4 days to fix my project. (I too value my time!)

I did check your release notes before posting and didn't see anything relevant to changing an atlas.  It may be fixed but I'm not going to check.

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: Editor null reference on changing sprite atlas
« Reply #3 on: November 25, 2013, 04:33:19 AM »
this error still occurs in 3.0.6 rc3

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Editor null reference on changing sprite atlas
« Reply #4 on: November 25, 2013, 05:01:57 AM »
Hmm... Can you tell me the steps you take so I can reproduce it and fix it for the next update?

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: Editor null reference on changing sprite atlas
« Reply #5 on: November 25, 2013, 07:28:46 AM »
It happens sometimes when changing the atlas via the atlas selection control in the sprite inspector window, I was unable to reliably reproduce it this way tho (typical!), I was able to reproduce it reliably by dragging an atlas from the project window into the atlas object control in the sprite inspector.

Note the current atlas and sprite must be valid and the atlas you're changing to must be different from the current one.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Editor null reference on changing sprite atlas
« Reply #6 on: November 25, 2013, 07:33:39 PM »
I'll have a look, thanks.