Whenever I press the Unity Editor's play button, I get this error:
Asked Answered
M

9

0
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.PropertyEditor.DrawEditors (UnityEditor.Editor[] editors) (at <4f969f18b6984883abf0f762caf9325d>:0)
UnityEditor.PropertyEditor.RebuildContentsContainers () (at <4f969f18b6984883abf0f762caf9325d>:0)
UnityEditor.InspectorWindow.RedrawFromNative () (at <4f969f18b6984883abf0f762caf9325d>:0)

Notes:

  • I still can play the scene, even with the error showing in the Console.
  • The error only pops up when I press the play button.
  • The error is clearable.

I think the error started about the time I played with the Canvas’s component Canvas Scaler I’M NOT SURE, but I undo all the changes, but the error still persists.

Moribund answered 4/10, 2023 at 18:8 Comment(0)
B
0

I was having a similiar issue! I had 2 inspectors opened in my project! Closing one of them made the error to stop (Using Unity 2020.3.5f1). Not sure if closing the inspector was the solution but it was the last thing I tried to make the error go away!

Bother answered 31/1 at 22:55 Comment(5)

I closed second inspector window and that error is gone, thank you. (Unity 2021.1.22)

Longing

I closed all duplicate panels ( Project and Inspector ) tabs and it worked.

Wirth

Thanks! Closing duplicate inspector window makes the error goes away. For me, it seems to happen since I place a CustomEditor script which filename does not match the editor class name into the project. Never had this error in 2019.4 though.

Mala

This was the cause of my issue too. Thanks!

Lynch

Yup, thats exactly what solved it for me :D

Telethon
S
0

Close all duplicate screens/Panels on the Unity editor and restart unity error will go away

Sandry answered 6/6, 2023 at 2:38 Comment(0)
B
0

Window > Layouts > Default

Worked for me.

Bolter answered 6/6, 2023 at 2:40 Comment(2)

This is so bizarre, especially since, to my knowledge, I didn't have any duplicate windows open, but it worked!!!! Thank you so much! (Unity 2020.3.24f1)

Quarrel

Incredible! I was going nuts with this and that was it! Thanks! (Unity 2020.3.28f1)

Bozen
L
0

Same problem here but it only went away by closing my inspector tab and re-opening it again.

Thanks anyway everyone!

Lympho answered 5/2, 2022 at 5:6 Comment(0)
E
0

Window → Layouts → Reset all layouts
(Unity 2020.3.27f)
It helped me

Ethelstan answered 6/6, 2023 at 2:39 Comment(0)
D
0

Restarting both visual studio and unity worked for me. I did not have two inspector windows open or anything like that. Hope this saves someone’s time. Simple restart.

Dewy answered 17/6, 2022 at 4:23 Comment(0)
F
0

That worked, I try to keep multi-tabs open from other areas, but once I closed my extra inspector I could demo the game again. Thank you!

-ONO

Fredrika answered 5/7, 2022 at 17:2 Comment(0)
W
0

As others have pointed out, having more than 1 instance of a menu in the editor can make that error appear, but it can also be due to the nature of Unity not being able to update the content of inactive tabs when you open the editor.


Just in case, make sure you switch to all tabs opened once after the error starts appearing. Chances are high that the error appears because one of the hidden tab tries to reach an old reference from a previous access that is now closed. (This is often the case of a 2nd inspector or a locked inspector menu which is why closing the 2nd one often does the trick.)


If you select the tab of an hidden/unfocused menu and the content of that menu is blank, but has the header of a selection, you have found the culprit. (For example, if an inspector has an icon and a name at the top, but display no component at all, that’s an example of when an Inspector UI attempt to reach a NULL reference.)


The solution: Either close any hidden/unfocused menus or select them and make sure their current selection is viable. (So, for example, make sure all Inspector has a proper selection, the Animator has a proper animation selected or none, the Controls (Input Actions) refers to the actual inputs action of the project, the Audio Mixer is properly selected, etc.) This error can also happen if you got a custom menu opened and it attempts to access some missing/unavailable files in a project. (As long as any UI elements in the editor attempt to access a NULL/unavailable reference, it will returns that error when you press Play.)

Winebibber answered 16/3, 2023 at 13:23 Comment(0)
V
0

Don’t select any gameobject in the hierarchy while playing make sure nothing is selected.

Verily answered 4/10, 2023 at 10:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.