Author Topic: Changing UISprite atlas makes inspector blank, errors  (Read 3805 times)

PaulGregory

  • Guest
Changing UISprite atlas makes inspector blank, errors
« on: November 29, 2013, 05:34:00 AM »
I'm using 3.0.6f6, and switching the UISlicedSprite on a load of buttons that were created with the SciFi Atlas to use my own imagery from my own Atlas.

I can change about 4 or 5 at a time before things start going wrong.

Upon changing the Atlas in the inspector, the inspector changes to be almost blanked out - just a small rectangle at the top left.

This error pops up in the console (4 times every time I return to Unity):

  1. NullReferenceException: Object reference not set to an instance of an object
  2. NGUIEditorTools.DrawSprite (UnityEngine.Texture2D tex, Rect drawRect, .UISpriteData sprite, Color color, UnityEngine.Material mat) (at Assets/NGUI/Scripts/Editor/NGUIEditorTools.cs:705)

If I select another thing in the Hierarchy I get these errors:

  1. The serializedObject should not be used inside OnSceneGUI or OnPreviewGUI. Use the target property directly instead.
  2. UnityEditor.GameObjectInspector:OnEnable()
  3.  
  4. The targets array should not be used inside OnSceneGUI or OnPreviewGUI. Use the single target property instead.
  5. UnityEditor.GameObjectInspector:OnEnable()

If I press Play and Stop, everything sorts itself out and I can continue changing the UISprite.

I'm on a Mac, and these are sprites that had been added with earlier versions of NGUI (3.0.x) if that makes any difference.

After a Play and Stop restart I can do 4 or 5 as I say but then the next one starts going mad.

This is rather annoying.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing UISprite atlas makes inspector blank, errors
« Reply #1 on: November 29, 2013, 09:00:47 AM »
UISlicedSprite has been removed back in 3.0.0, and has been only left for backwards compatibility in the upgrade package. Did you run the upgrade tool to auto-upgrade all of them to normal sprites set to sliced mode?

PaulGregory

  • Guest
Re: Changing UISprite atlas makes inspector blank, errors
« Reply #2 on: November 29, 2013, 10:42:41 AM »
I did not use NGUI before 3.0.something so I have had no need of the upgrade package. I could do with one from 3.0.5 to 3.0.6 though!

The component *is* a UISprite with the sprite mode set to sliced. The object has the name/label UISlicedSprite, probably from the sample stuff.

Having ploughed through with it (as there is a workaround of play/stop), I can say that sometimes I got the error straight away (ie first sprite, not 4th or 5th).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing UISprite atlas makes inspector blank, errors
« Reply #3 on: November 29, 2013, 10:51:40 AM »
Curious. Well, on line 701 of the same file (NGUIEditorTools) there is a check:
  1. if (!tex) return;
Change it to:
  1. if (!tex || sprite == null) return;