MissingReferenceException with two Inspectors open

Klin

Member
Unity 2020.3
UIS 1.2.3

Hi Santiago,

when I have two inspectors open and start play-mode, I get :

1637829738906.png
1637830227272.png
It's not a big deal but it took me a while to figure out what the cause is (and I searched for it two times after forgetting it 2 weeks later, that's why I'm posting this ;-)

Maybe it's possible to resolve it with a simple nullcheck?

Best regards.
 
Last edited:

Sangemdoko

Moderator
Staff member
Odd. Would you mind sending me the full error message? The error screen shot you sent does not give me enough information to go on.
 

Klin

Member
MissingReferenceException: The object of type 'InventoryItemSetManager' 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.
UnityEngine.Component.GetComponent[T] () (at <10564ed154d647e194bef4aef8878649>:0)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.Editor.InventoryItemSetManagerInspector.CreateInspectorGUI () (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Editor/InventoryItemSetManagerInspector.cs:48)
UnityEditor.UIElements.InspectorElement.CreateInspectorElementFromEditor (UnityEditor.Editor editor, System.Boolean reuseIMGUIContainer) (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEditor.UIElements.InspectorElement.Reset (UnityEditor.SerializedObject bindObject) (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEditor.UIElements.InspectorElement.ExecuteDefaultActionAtTarget (UnityEngine.UIElements.EventBase evt) (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <1cdf5c2cc10149169242b9590b7ebb6b>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <1cdf5c2cc10149169242b9590b7ebb6b>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.SendBindingEvent[TEventType] (TEventType evt, UnityEngine.UIElements.VisualElement target) (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindTree (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.ContinueBinding (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.Bind (UnityEngine.UIElements.VisualElement element) (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation.Bind (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedObject obj) (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEditor.UIElements.BindingExtensions.Bind (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedObject obj) (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEditor.UIElements.InspectorElement..ctor (UnityEditor.Editor editor, UnityEditor.UIElements.InspectorElement+Mode mode) (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEditor.UIElements.EditorElement.Init () (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEditor.UIElements.EditorElement..ctor (System.Int32 editorIndex, UnityEditor.IPropertyView iw, System.Boolean isCulled) (at <0fdaf67e8e744beea25e77915c19f81b>:0)
UnityEditor.EditorUIServiceImpl.CreateEditorElement (System.Int32 editorIndex, UnityEditor.IPropertyView iw, System.String title) (at <5f5866ec908d4054a9597064f39dbbac>:0)
UnityEditor.PropertyEditor.DrawEditors (UnityEditor.Editor[] editors) (at <d6a6a4b561b9431dbfe2c61f7bf0d405>:0)
UnityEditor.PropertyEditor.RebuildContentsContainers () (at <d6a6a4b561b9431dbfe2c61f7bf0d405>:0)
UnityEditor.InspectorWindow.RedrawFromNative () (at <d6a6a4b561b9431dbfe2c61f7bf0d405>:0)
 

Sangemdoko

Moderator
Staff member
Thank you here is the updated code:

Code:
/// <summary>
/// Create a custom inspector by drawing all serialized fields as UIElements.
/// </summary>
/// <returns>The custom inspector.</returns>
public override VisualElement CreateInspectorGUI()
{
    var container = new VisualElement();
    
    m_InventoryItemSetManager = target as InventoryItemSetManager;
    if (m_InventoryItemSetManager == null) {
        Debug.LogWarning("The Inventory Item Set Manager was null in the custom inspector.\n" +
                         "This can happen if multiple Inspectors are opened at the same time.");
        return container;
    }
 
Top