Search Issue Tracker
Fixed
Fixed in 5.0.6, 5.1.2
Votes
16
Found in [Package]
5.0.3
5.1.0
Issue ID
WBTRB-105
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
Comments (5)
-
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++)
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
- Circle handle of the Game view scale slider bar disappears when the scale is set to 1x
- Asset Bundles non-deterministic behavior with CRCs and hash when a video has Transcoding enabled and Sprite Atlas has an override option enabled
- [Quality Hackweek] Errors "InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread" and "NullReferenceException" shown when switching build platforms with Muse Texture package installed
- "Importer(DefaultImporter) generated inconsistent result for asset" warnings are thrown when reimporting the "URP" texture
- Material property block emits and reflects incorrect color when baked Indirect Light is used
Resolution Note:
Thank you for bringing this issue to our attention. Unfortunately, after careful consideration we will not be addressing your issue at this time, as we are currently committed to resolving other higher-priority issues.
We acknowledge that the current Terrain system has a number of limitations, so we are currently investing in a large amount of discovery work to determine exactly what is needed most and how we can bring it to you at the quality level you have come to expect and address the most pervasive pain points in the most effective and efficient manner. However, we know each case is different, so please do continue to log any issues you find, and provide general feedback on our roadmap page to help us prioritize.
Forum to discuss feature requests: https://forum.unity.com/threads/world-building-public-roadmap-and-feature-requests.1437163/
Roadmap: https://unity.com/roadmap/unity-platform/3d-world-building
Resolution Note (fix version 5.1.2):
Note: this issue was resolved in version 5.2.1 of the Terrain Tools package.