UnityEditor.PrefabImporterEditor has not been disposed correctly error

When I try to add a new component to a prefab, two error just appear :

The previous instance of UnityEditor.PrefabImporterEditor has not been disposed correctly. Make sure you are calling base.OnDisable() in your AssetImporterEditor implementation.
UnityEditor.PrefabImporterEditor:OnDestroy()

The previous instance of UnityEditor.PrefabImporterEditor has not been disposed correctly. Make sure you are calling base.OnDisable() in your AssetImporterEditor implementation.
UnityEditor.Experimental.AssetImporters.AssetImporterEditor:InternalSetTargets(Object[ ])

that seemed to happen after unity crash, what should i do?

I got the same issue, however this happens to me only when I’m selecting a specefic gameObject.
That gameObject has a script that schanges its mesh, does your bug appears when selecting specific prefabs as well?

1 Like

Okay, i THINK I have fixed the probleme.
the prefabs that were “buggy” were changing there mesh in th onValidate function wich is also called when the prefab is selected in the project window.
Basically i just putted everything I had in the onValidate function in an if statement if (isActiveAndEnabled)
and I got read of the bug

So maybe objects are being changed when selected in the project editor?

2 Likes

Thanks Kantic, this also fixed a similar issue I was having. Was setting properties of line renderer in OnValidate. Adding an early out if not isActiveAndEnabled fixed the issue for me.

    private void OnValidate()
    {
        if (!isActiveAndEnabled)
        {
            return;
        }

        lineRenderer = GetComponent<LineRenderer>();
        lineRenderer.useWorldSpace = true;
        lineRenderer.startWidth = width;
        lineRenderer.endWidth = width;
        lineRenderer.sharedMaterial = material;
        lineRenderer.startColor = color;
        lineRenderer.endColor = color;
    }
1 Like