Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by dandeto · May 02, 2020 at 11:12 PM · buildnullreferenceexceptionbuild settingsnewbuild and run

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Venkify · May 20, 2020 at 07:07 AM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image aleposchenrieder · Sep 04, 2020 at 11:24 PM 0
Share

This was the solution for me. I was using Sprite Shape Renderer without a profile and it worked great in the Editor but it didn't wok in the Android build. I just created a new profile and set it to the Sprite shape renderer, now it works like a charm.

avatar image
0

Answer by dandeto · May 03, 2020 at 05:54 PM

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image kalle18 · May 06, 2020 at 07:28 PM 0
Share

Unforunately I don't have the answer for you, but I can feel with you. I can confirm the same behavior.

I have a little 2D prototype, mixed with sprites AND spriteshapes (not quite sure what the difference is either). I used the spriteshape for a dynamic background color of sprites. I've chosen the spriteshape because you can make some shape with a defined color and don't need to provide any image, so it was just for quick prototyping.

I can run the game in preview mode but once I build the game (Windows x64) I get NullReferenceExceptions and no spriteshapes are rendered:

 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] 

avatar image dandeto · May 08, 2020 at 06:28 PM 0
Share

Quick for prototyping - exactly why I chose spriteshape! It actually made my game lag on top of not building. I converted everything to sprites and it runs so much nicer and will build. I'm glad you confirmed that it's an issue, though.

avatar image oriolmanya · May 17, 2020 at 08:47 PM 0
Share

The SpriteShapes are crashing my project as well with same error but on an Android Build. It's depressing, because I was just moving all my assets from Ferr2D to Sprite Shapes; and as like with another 2D features, - like Anima2D - I have the feeling they are being sloppy and unfocused with 2D libraries.

I'd try to Report a Bug, but it's so much job. If I don't find any other thread with the solution I'll have to do it.

avatar image
0

Answer by oriolmanya · May 17, 2020 at 09:56 PM

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

  • So I sended a Bug Report (with code case 1248133)

  • I started this thread in the forum to know if more people are experiencing the problemand give awarenes to this error that I judge critical:

  • Forum link: https://forum.unity.com/threads/sprites-shapes-crash-on-android-build-v-2019-3-13.892567/

    [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."

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

216 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Build button is greyed out for Universal Windows Platforms 0 Answers

My builded game is resized! 1 Answer

how can i fix building game? 1 Answer

Unity build only ask's permission on android publish but not when I build and test? 0 Answers

Unity Start not called on build, but it does when testing 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges