Search Issue Tracker
Active
Under Consideration for 2022.2.X, 2022.3.X
Votes
15
Found in
2022.2.0b1
Issue ID
UUM-9856
Regression
No
Terrain Toolbox window causes an exception after entering and leaving play mode
Steps to reproduce:
# Load the attached project
# Ensure that the Terrain Tools window (Window/Terrain/Terrain Toolbox) is open and docked somewhere
# Open Scene Assets/Scenes/SampleScene.unity
# Enter & exit Play Mode
Expected result: nothing happens
Actual result:
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 /Users/ascentress/Desktop/lotad2/Library/PackageCache/com.unity.terrain-tools@5.0.0-pre.3/Editor/TerrainToolbox/TerrainToolboxUtilities.cs:2061)
UnityEditor.TerrainTools.TerrainToolboxUtilities.OnPlayModeChanged (UnityEditor.PlayModeStateChange state) (at /Users/ascentress/Desktop/lotad2/Library/PackageCache/com.unity.terrain-tools@5.0.0-pre.3/Editor/TerrainToolbox/TerrainToolboxUtilities.cs:2290)
UnityEditor.EditorApplication.Internal_PlayModeStateChanged (UnityEditor.PlayModeStateChange state) (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorApplication.cs:441)
Reproducible with any version that supports the Terrain Tools package versions 4.0.3 and above.
Package version: 4.0.3, 5.0.0-pre.3
Tested Editor versions: 2021.3.1f1, 2022.2.0b1
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Crash when trying to force Shader to interpret 1/30 as a floating point operation
- Terrain is flickering when adjusting "Compatibility Mode" and "Use Rendering Layers" Settings
- Isometric tiles are flickering and overlapping each other when entering Play Mode with Tilemap Renderer mode set to "Chunk"
- Crash on ParticleSystemParticles::array_reserve when particle system starts
- Docking Text Property Preview Window next to UI Builder breaks the window and causes NullReferenceException
Freshione
Jul 07, 2024 13:11
Tried FLAMINGJEZ solution but now my project has got bricked for modifying the script.
ScriptableSingleton already exists. Did you query the singleton in a constructor?
UnityEditor.PackageManager.UI.Internal.PackageManagerProjectSettings:.ctor ()
Restarting fixes the error message, but now some parts of my game wont work.
rayanivanove
Jan 11, 2024 16:24
MELZERIA: You need to clear the error from the console before making the changes in visual studio, for some reason, and then it should work.
Melzeria
Jul 16, 2023 11:25
I tried your solution to fix this but everything I add the else and click on save, the script just automatically reverts back to what it had before and I keep getting the error message.
Om1010
Apr 02, 2023 15:08
Thanks FLAMINGJEZ, It totally worked and I learned something new that I could've never had!
FlamingJez
Aug 06, 2022 16:30
I fixed this myself as it was quite annoying. if you double click the error it should take you into the TerrainToolboxUtilities.cs. The error is that on line 1853 it's trying to call DisabledKeyword when m_PreviewMaterial is null. There's already an if statement checking if it's null, so i just added an else so the line only runs when m_PreviewMaterial has been assigned.
internal void RevertPreviewMaterial()
{
if (m_PreviewMaterial == null)
{
GetAndSetActiveRenderPipelineSettings();
}
else
{
m_PreviewMaterial.DisableKeyword("_SPLATMAP_PREVIEW");
}
for (int i = 0; i < m_Terrains.Length; i++)