Search Issue Tracker
Fixed in 2021.1.X
Votes
0
Found in
2019.3
2020.1
2020.2
2020.2.0a9
Issue ID
1240871
Regression
No
[Terrain] MissingReferenceException thrown on creating Material under Terrain Settings in Preset of Terrain
When A preset of a Terrain GameObject is created and a new Material is created for "Basic Terrain" from "Terrain Settings", then it causes the editor to throw the following errors:
1. Undo object may not be null.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
2.MissingReferenceException: The object of type 'Terrain' has been destroyed but you are still trying to access it, refer the attached video
Steps to repro:
1. Create a new project.
2. Hierarchy > Create > 3D Object > Terrain
3. Create Preset of Terrain
4. Project > Terrain > Inspector > Activate this inspector
5. Terrain Settings > Basic Terrain > Material > Create a New Material
Actual Result:
Undo object may not be null and MissingReferenceException are thrown on Creating Material under Terrain Settings when preset of Terrain is created
Expected Result:
Material is created without throwing any exception in the console
Note: Changes in the preset file can be made from Unity 2019.3.0a6 onwards. In the earlier versions making changes in the preset file was not introduced
Occurring in:
2020.2.0a8, 2020.1.0b7, 2019.3.10f1, 2019.3.0a6
Environment:
Windows 10 & macOS 10.14
Stack trace:
Undo object may not be null.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
MissingReferenceException: The object of type 'Terrain' 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.TerrainInspector+DoCreateTerrainMaterial.Action (System.Int32 instanceId, System.String pathName, System.String resourceFile) (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.ProjectWindowUtil.EndNameEditAction (UnityEditor.ProjectWindowCallback.EndNameEditAction action, System.Int32 instanceId, System.String pathName, System.String resourceFile, System.Boolean accepted) (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.CreateAssetUtility.EndNewAssetCreation (System.String name) (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.AssetsTreeViewGUI.RenameEnded () (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.IMGUI.Controls.TreeViewGUI.EndRename () (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.IMGUI.Controls.TreeViewGUI.DoRenameOverlay () (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.IMGUI.Controls.TreeViewGUI.BeginRowGUI () (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.AssetsTreeViewGUI.BeginRowGUI () (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.IMGUI.Controls.TreeViewController.OnGUI (UnityEngine.Rect rect, System.Int32 keyboardControlID) (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.ProjectBrowser.OnGUI () (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEditor.DockArea.OldOnGUI () (at <5951c2421c324f47883bd5ba8a4bf507>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.MouseEventDispatchingStrategy.SendEventToRegularTarget (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.MouseEventDispatchingStrategy.SendEventToTarget (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.MouseEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel iPanel) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <24c50376b86c43d4b31e43f2eea74de6>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <5ef95cf9017f426f8b888bbcd7fe1bcc>:0)
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Shader Graph Asset icon is not shown on creation unless you confirm the name
- APV Sky occlusion doesn't consider the terrain
- [iOS] "EXC_BAD_ACCESS" Player crash when Script Debugging is enabled
- Cursor skips input fields when tabbing between two sets of input fields
- "Shader error redefinition of 'Varyings'" error appears when selecting the shader
Add comment