• 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 /
avatar image
4
Question by kk93 · Apr 28, 2014 at 09:23 PM · nullreferenceexception

NullReferenceException UnityEditor.SerializedObject..ctor

Hello,

I keep getting the following error whenever I run my game:

NullReferenceException: (null) UnityEditor.SerializedObject..ctor (UnityEngine.Object[] objs) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/SerializedPropertyBindings.cs:69) UnityEditor.Editor.GetSerializedObjectInternal () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/EditorBindings.cs:117) UnityEditor.Editor.get_serializedObject () (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/EditorBindings.cs:110) UnityEditor.MeshRendererEditor.OnEnable () (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/Inspector/MeshRendererEditor.cs:16)

I consistently get 6 of them. The problem is that when I click it, it doesn't take me to where in the script the error is so I have absolutely no clue how to debug this. I should mention that the game runs absolutely fine with the error, but I do not want this to cause any unexpected problem in the future.

How do I approach a problem like this?

Comment
Add comment · Show 1
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 0V3RR1D3 · Apr 28, 2014 at 09:39 PM 0
Share

What is your code?

4 Replies

· Add your reply
  • Sort: 
avatar image
24
Best Answer

Answer by kk93 · Apr 28, 2014 at 10:01 PM

Funny story... my Unity froze while I was trying to debug this, and when I restarted Unity the problem disappeared. So... I guess that's the answer.

Comment
Add comment · Show 6 · 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 Stealthygolem · Oct 18, 2014 at 01:52 PM 0
Share

That answer was short, simple, and it worked for me. Thank you :)

avatar image Syphio · Jun 03, 2015 at 09:44 PM 0
Share

Same here, was porting some models and animations from Blender to Unity and it popped around for no reason - restarting Unity fixed it. I guess its a engine issue?

avatar image arfan447 · May 17, 2016 at 12:57 PM 0
Share

hahaha its amazing only restart the unity remove the stupied error........ =D

avatar image Ridhuan-Naim · Nov 23, 2016 at 02:41 AM 0
Share

yep, this still happens on ver 5.4.1f1, restart unity solved it.

avatar image thedarcsage · Apr 29, 2017 at 06:00 AM 0
Share

5.6.0f3 here, but simply restarting it worked for me - thanks

Show more comments
avatar image
3

Answer by _watcher_ · May 19, 2019 at 03:26 PM

Hate to necro this, but since it persists in 19.1.1f1: The problem is, you're previewing a Serialized object from your Project, in one (or both) of your Inspector windows. When you have 2 (or more) Inspector windows open while you preview a ScriptableObject Asset, you'll get that error and be unable to compile. The reason why "it fixed itself" by restarting Unity is that your Windows Layout did not save, so you restarted with only 1 Inspector window open.

TLDR: Close any other Inspector Windows you have open while previewing a Serialized object asset. Make sure you have only 1 Inspector Window open, while previewing your SerializedObject Asset.

I've submitted a Bug Report to hopefully have this fixed in the future.

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 cobertos · Jun 03, 2019 at 11:34 PM 0
Share

I'm getting the exact same issue but when developing my own custom inspector for a specifc $$anonymous$$onoBehavior. It consistently happens in 2019.1 after I exit play mode. $$anonymous$$y custom inspector will also break when trying to access the serializedProperty member.

Can you link the Bug Report? I'd be interested in it

avatar image
1

Answer by blackrose259 · Jun 28, 2018 at 03:39 PM

Changed "Mask" to "Rect Mask 2D"

https://issuetracker.unity3d.com/issues/nullreferenceexception-when-using-a-scroll-view

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
1

Answer by JaviTheGreat · May 18, 2017 at 12:57 PM

I still see the issue (Unity 5.6.0f3)... alt text

My configuration... alt text

Repro steps...

  1. Create a configuration like in the second image (the material doesn't matter actually)

  2. Run the game with the GameObject selected (it has to be selected before running the game)

Restarting the IDE makes it disappear but only until you select the GameObject again.

Note: The game works as expected. It's just an annoying error message.

Best regards.


screen-shot-2017-05-16-at-145737.png (42.6 kB)
screen-shot-2017-05-16-at-145724.png (30.1 kB)
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 ccGamerDude · Jun 20, 2017 at 05:30 PM 0
Share

Hey JaviTheGreat, I had the same problem. Restarting worked. I think the reason for the message is that there might be some variables which are initialized in the inspector and also in the start function of some script. Remove one of them, and it should help.

avatar image LucasKlein16 · Jul 06, 2017 at 04:06 AM 0
Share

did you file a bug report on this?

avatar image leorin · Jul 29, 2017 at 10:16 PM 0
Share

Exactly same error here. It appeared after i deleted scrollbars i think but not sure. When i select one of gameobjects inside scrollview's content and start game i get this error.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

38 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

Related Questions

Object reference not set to an instance of an object 1 Answer

NullReferenceException: Object reference not set to an instance of an object CannonFire.Update 0 Answers

NullReference Exception with GameObjects across classes 0 Answers

NRE in my Inventory GUI 1 Answer

Allocating Game Object name dynamically using Find 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