After creating a brand new terrain using the Unity Terrain Toolbox (version 4.0.3) my project now constantly has the exception:
MissingReferenceException: The object of type ‘Material’ 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.
UnityEditor.TerrainTools.TerrainToolboxUtilities.RevertPreviewMaterial () (at Library/PackageCache/com.unity.terrain-tools@4.0.3/Editor/TerrainToolbox/TerrainToolboxUtilities.cs:1853)
UnityEditor.TerrainTools.TerrainToolboxUtilities.OnPlayModeChanged (UnityEditor.PlayModeStateChange state) (at Library/PackageCache/com.unity.terrain-tools@4.0.3/Editor/TerrainToolbox/TerrainToolboxUtilities.cs:2082)
UnityEditor.EditorApplication.Internal_PlayModeStateChanged (UnityEditor.PlayModeStateChange state) (at :0)
Does anyone know a workaround to resolve this? Or should I scrap the toolbox and try to create terrains the normal way?
Right now the Toolbox is so full of issues like this that I can’t recommend even using it for testing purposes. It is just constantly throwing up errors when doing even basic tasks.
Is there any Unity dev support looking at this?
It’s a released Unity official package and it’s been out of preview since September of 2021.
It looks like there were several updates right after 4.0.0, and then nothing.
I’ve submitted a bug report on this. It’s really annoying and surprising to see in a released Unity official package.
Close Unity Editor, but leave Visual Studio open with the code then add the “return;” line. I can’t confirm it will work, but judging by the warning my Visual Studio gave me Unity Editor was a little mad at me for trying to change it while it was using that script at the time. I accepted the revert Visual Studio was offering when it asked, but quickly added the line back in and hit save before it was looking and that worked for me.
I have this problem too, It was working for me on a project I had created earlier that I updated the version of the editor maybe twice or three times.
But I reset my packages to default and this error is keep appearing, really bugging me out
I GOT IT!
So what you gotta do is download one of the previous of LTS 2021 and start a project. Maybe add a cube or something save and close the project. After that update the project editor version to latest version and there won’t be this error.
I had this problem and I think it is because I had the Terrain Toolbox window open (or attached to somewhere in the unity window). Just close the Terrain Toolbox window and the error should dissapear.