gasgiant / Markup-Attributes

A Unity Editor extension for customizing inspector layout with attributes.
MIT License
289 stars 11 forks source link

[BUG] MarkedUp throws lots of error when script is missing #7

Open Whyser opened 2 years ago

Whyser commented 2 years ago

Hey and again, awesome lib!

If I delete a Script/Component from project. MarkedUp will throw lots of errors when trying to "MarkUp" a GameObject with "missing scripts". For now I've solved it with (inside: MarkedUpEditor.cs):

if (serializedObject.targetObject != null)
{
    isInitialized = true;

    EditorLayoutDataBuilder.BuildLayoutData(serializedObject, out allProps,
        out firstLevelProps, out layoutData, out inlineEditors, out targetsRequireUpdate);
    layoutController = new InspectorLayoutController(target.GetType().FullName,
        layoutData.ToArray());
    callbackManager = new CallbackManager(firstLevelProps);
    OnInitialize();
}
else
{
    UnityEngine.Debug.LogError(target.name + " probably has a Component that doesn't exist anymore! Please remove the missing Component.", target);
}

Also had to add 'isInitialized' to prevent other code from running if Initialization hasn't been done properly. I've not had the time to dig any deeper into a better solution. :)

gasgiant commented 2 years ago

Hi! Thank you for letting me know. I'll look into it and make a proper fix.