prime31 / SpriteKit

DEFUNCT: Unity now has 2D tools built in. This is now not maintained.
15 stars 7 forks source link

MissingReferenceException when creating a new sprite sheet #1

Open rocket5 opened 11 years ago

rocket5 commented 11 years ago

Frequently when making a new sprite sheet with the "new sprite sheet wizard", I'm getting a MissingReferenceException (see below). When this occurs, the _sheet file in Resources/SpriteSheets is not created and the wizard window doesn't dismiss as it does when everything is created properly. If I click the "create sprite sheet" button again (sometimes 3 or 4 times), eventually the the _sheet file will be created, the warning won't display and the wizard window will close itself properly.

I'm using Unity 4.1 pro with iPhone pro

Here's a project file that should reproduce the bug: https://dl.dropbox.com/u/3302748/_TempSpriteKitTest.zip

MissingReferenceException: The object of type 'SKSpriteSheet' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. SKTextureUtil.createSpriteSheet (System.String name, System.String sourceFolder, Boolean generateSdTexture, Int32 cameraOrthoSize, Int32 targetScreenHeight) (at Assets/SpriteKit/Editor/SKTextureUtil.cs:118) SKNewSpriteSheetWizard.OnGUI () (at Assets/SpriteKit/Editor/SKNewSpriteSheetWizard.cs:59) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System.Reflection/MonoMethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System.Reflection/MonoMethod.cs:232) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System.Reflection/MethodBase.cs:115) UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) UnityEditor.HostView.Invoke (System.String methodName) UnityEditor.HostView.OnGUI ()

bzgeb commented 11 years ago

I had the same problem. This altered SKTextureUtil.cs fixed it for me https://gist.github.com/bzgeb/5671545. I think it's a Unity Editor bug caused by creating two assets, the spritesheet material file, and the spritesheet ScriptableObject one after another, which doesn't make any logical sense without seeing the code for AssetDatabase.CreateAsset().