TylerTemp / SaintsField

A Unity Inspector extension tool focusing on script fields inspector enhancement
MIT License
148 stars 9 forks source link

SerializedObjectNotCreatableException after domain reload #10

Closed hailin-lee closed 4 months ago

hailin-lee commented 4 months ago

After Apply SaintsEditor, each time modify come code, after domain reload, SerializedObjectNotCreatableException is logged as below:

SerializedObjectNotCreatableException: Object at index 0 is null UnityEditor.Editor.CreateSerializedObject () (at /Users/bokken/build/output/unity/unity/Editor/Mono/Inspector/Editor.cs:698) UnityEditor.Editor.GetSerializedObjectInternal () (at /Users/bokken/build/output/unity/unity/Editor/Mono/Inspector/Editor.cs:670) UnityEditor.Editor.get_serializedObject () (at /Users/bokken/build/output/unity/unity/Editor/Mono/Inspector/Editor.cs:564) SaintsField.Editor.SaintsEditor.OnEnable () (at ./Library/PackageCache/today.comes.saintsfield@4d69fe59bd/Editor/SaintsEditor.cs:129)

It seems something buggy inside SaintsEditor.OnEnable().

TylerTemp commented 4 months ago

Hi, thanks for reporting.

I did notice this kind of unexpected behavior sometimes, but it's kinda unstable to re-produce.

I tried:

Attach this to an empty object in an empty scene:

public class Anything: MonoBehaviour
{
    [PropRange(0, 10)]
    [PlayaDisableIf]
    public int value3;

    [PlayaDisableIf] public string value4;

    public void Start()
    {
        Debug.Log("Hello Again!");
    }
}

Wait for Unity to compile.

Then modify the function and back to unity, no error gives. modify the field, no errors either. (Tested on IMGUI & UI Toolkit)


Sadly, somehow I can not re-produce it even I've seen it before (((

Appreciated if you can provide a guide of how to re-produce it, with the information:

[FieldType(typeof(SpriteRenderer))]
public GameObject sr;

IMGUI looks like (two selector buttons at the end):

image

UI Toolkit looks like (one selector button at the end):

image

And if possible, a code fragment and a way to re-produce it:

// Your code

Thanks in advance!

TylerTemp commented 4 months ago

Hi @hailin-lee , this BUG might get fixed in 2.3.5. Without more information I can not identify which cause this problem, so please have a try in new version.

TylerTemp commented 4 months ago

Closed due to lack of activity.