- Home /
Why I'm getting only sometimes : MissingReferenceException: The object of type ... But none of the scripts exist on my hard drive ?
I'm using unity 2019.2.5f1 personal
The problem happen sometimes when I click the PLAY button in the editor to STOP the game ! Or when switching to main menu by hit the escape key.
Sometimes it happens sometimes not.
And the strange thing is that all the scripts in the exception message are not exist on my hard drives. I did a search for my whole pc many times the scripts in the exception message are not exist !
I have in the Hierarchy some Reflections Probes :
In the screenshot on the left a group of some reflections probes and the inspector settings. and on the right another one in the bottom of my Hierarchy with his inspector settings.
![Reflections Probes][1]
And I have a empty gameobject with this script attached : The gameplay scene is at index 1 the main menu is at index 0.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class BackToMainMenu : MonoBehaviour
{
public PlayerCameraMouseLook cammouselook;
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
PlayerCameraMouseLook.mouseLookEnable = false;
cammouselook.enabled = true;
}
}
}
When pressing on escape while the game is running the main gameplay scene is removed/unloaded and it's loading the main menu scene.
I tried like 20 times now to run the game and press escape and it was fine. But at the 21 time test for some reason it throw the exception in the editor. Most of time it's not showing the exception but sometimes it does :
I couldn't find in my Hierarchy any object with a script that use or try to access ant of the reflection probes.
And also the exception message is not pointing to one of my scripts that is try to access it so I don't know if at all and what script is trying to access any of the reflection probes.
Your script should either check if it is null or you should not destroy the object. UnityEditor.ReflectionProbeEditor.OnPreSceneGUICallback (UnityEditor.SceneView sceneView) (at C:/buildslave/unity/build/Editor/Mono/Inspector/ReflectionProbeEditor.cs:651) UnityEditor.SceneView.CallOnPreSceneGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:3359) UnityEditor.SceneView.DoOnPreSceneGUICallbacks (UnityEngine.Rect cameraRect) (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1935) UnityEditor.SceneView.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2320) System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at :0) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. UnityEngine.UIElements.UIR.RenderChain.Render (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at C:/buildslave/unity/build/Modules/UIElements/Renderer/UIRChainBuilder.cs:238) UnityEngine.UIElements.UIRRepaintUpdater.DrawChain (UnityEngine.Rect topRect, UnityEngine.Matrix4x4 projection) (at C:/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:66) UnityEngine.UIElements.UIRRepaintUpdater.Update () (at C:/buildslave/unity/build/Modules/UIElements/Renderer/UIRRepaintUpdater.cs:54) UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTree () (at C:/buildslave/unity/build/Modules/UIElements/VisualTreeUpdater.cs:72) UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at C:/buildslave/unity/build/Modules/UIElements/Panel.cs:637) UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:240) UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:78) UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179) [1]: /storage/temp/146849-reflectionprobes1.jpgMissingReferenceException: The object of type 'ReflectionProbe' has been destroyed but you are still trying to access it.
Your answer
![](https://koobas.hobune.stream/wayback/20220612212808im_/https://answers.unity.com/themes/thub/images/avi.jpg)