Unity 2019.3.12f1 New Project Build NullReferenceException Causes only Background Color to Render

Hello Everyone! I’m new to Unity 2019.

When I make a 2d project, put one GameObject into the scene and run it, I can see it when I preview the game. When I build the game on Windows 32, 64, or WebGL, I get a blue screen - or whatever the background color of the camera is. If I decide to add audio, that will play, but the graphics will not render. In build settings, I select the scene to add to the build. I have created new scenes and new projects to try that as well. All to no avail.

I have seen several of these issues posted, but either they are never resolved, or the issue is trivial and not relevant to me. I ran in debug mode (because I wanted to see what the problem is) and I get a NullReferenceException. Please note that I have not written any scripts. Only added a single sprite.

I looked in the logs and found this repeated a million times:

NullReferenceException: Object reference not set to an instance of an object
  at Unity.Collections.NativeSlice`1[T].get_Item (System.Int32 index) [0x00001] in C:\buildslave\unity\build\Runtime\Export\NativeArray\NativeSlice.cs:200 
  at UnityEngine.U2D.SpriteShapeGenerator.TessellateContour () [0x00192] in C:\Unity\Breakout2\Library\PackageCache\com.unity.2d.spriteshape@3.0.10\Runtime\SpriteShapeGenerator.cs:1001 
  at UnityEngine.U2D.SpriteShapeGenerator.Prepare (UnityEngine.U2D.SpriteShapeController controller, UnityEngine.U2D.SpriteShapeParameters shapeParams, System.Int32 maxArrayCount, Unity.Collections.NativeArray`1[T] shapePoints, Unity.Collections.NativeArray`1[T] metaData, UnityEngine.U2D.AngleRangeInfo[] angleRanges, UnityEngine.Sprite[] segmentSprites, UnityEngine.Sprite[] cornerSprites) [0x00051] in C:\Unity\Breakout2\Library\PackageCache\com.unity.2d.spriteshape@3.0.10\Runtime\SpriteShapeGenerator.cs:2073 
  at UnityEngine.U2D.SpriteShapeController.BakeMesh (System.Boolean needUpdateSpriteArrays) [0x00371] in C:\Unity\Breakout2\Library\PackageCache\com.unity.2d.spriteshape@3.0.10\Runtime\SpriteShapeController.cs:479 
  at UnityEngine.U2D.SpriteShapeController.OnWillRenderObject () [0x0002d] in C:\Unity\Breakout2\Library\PackageCache\com.unity.2d.spriteshape@3.0.10\Runtime\SpriteShapeController.cs:351 
 
(Filename: C:/buildslave/unity/build/Runtime/Export/NativeArray/NativeSlice.cs Line: 200)

I have no idea where to go from here. I have searched the web extensively. Any help would be appreciated. I have a Zotac GTX 1060 Ti 6gb graphics card, by the way.

Sorry for the delay in response. We do frequently try to respond in forums.

@dandeto @kalle18
Please ensure that you have a valid SpriteShape profile set in the SpriteShapeController. A simple SpriteShape profile with a 4x4 white texture set to repeat mode as fill texture can be set to these objects. We have addressed this issue and added a warning if a valid Profile is not set in recent versions.

@dandeto SpriteShape data is stored in a very compact form and the geometry is only generated once on the Runtime as long as there are no changes. It is generally fast and when Burst package is installed its quite faster as it utilizes C# jobs to generate the geometry. Could you kindly provide a simple repro project where is slow. We will try to take a look asap.

Sorry for the inconvenience caused.

UPDATE

I looked at the logs more and experimented. I removed everything from the scene except for the camera. When I made my test scene, the ONE gameobject I decided to put in the scene was a SpriteShape. I removed it and added a single sprite. The game built and rendered like normal with no errors.

So here is a follow up question based on my new findings: Why in the world does Unity break the build when I have a spriteshape in my scene, but it is fine with any other object. Furthermore, why does the console not throw any errors when I preview the game?

I’m not really sure what the difference between a sprite and spriteshape is, I just wanted to draw shapes in a little test 2D game because I didn’t have any actual sprites drawn.

I will reinstall Unity to see if that fixes anything because this behavior seems wildly broken. Please correct me if I’m wrong.

Hi guys, as I said in the comment, It happens to me as well when publishing on Android .

[Edit]
Solution:

I quote as @Venkify from Unity answered me in the forum, and it worked:

“Please ensure that you set a valid
SpriteShape profile for all the
SpriteShapeController Objects in the
scene. This should fix the issue. In
Editor, we allow editing SpriteShape
without having a valid SpriteShape
profile to prototype easier. But a
valid SpriteShape profile is required
to be set for runtime to render
properly. A simple SpriteShape profile
with a 4x4 white texture set to repeat
mode as fill texture can be set to
these objects.”