AnnulusGames / LucidEditor

Powerful Editor Extensions for Unity
MIT License
127 stars 13 forks source link

Nested serializable class can't be serialized. #7

Open Nu99et opened 1 year ago

Nu99et commented 1 year ago

Type in use (some code is omitted)

public abstract class View<TBinding>
{
     [SerializeField] private TBinding binding;
    protected TBinding Binding => binding;
}

public class MyView : View<MyView.MyBinding>
{
    [Serializable]
    public class MyBinding
    {
        public Text text;
    }
}

When the package is removed, this type could be serialized well.

Stacktrace

NullReferenceException: Object reference not set to an instance of an object
AnnulusGames.LucidTools.Editor.SerializedPropertyExtensions.GetFieldInfo (UnityEditor.SerializedProperty property) (at ./Library/PackageCache/com.annulusgames.lucid-editor@3747d977e2/Editor/Extensions/SerializedPropertyExtensions.cs:154)
AnnulusGames.LucidTools.Editor.InspectorPropertyUtil.CreateChildProperties (AnnulusGames.LucidTools.Editor.InspectorField property) (at ./Library/PackageCache/com.annulusgames.lucid-editor@3747d977e2/Editor/Utils/InspectorPropertyUtil.cs:38)
AnnulusGames.LucidTools.Editor.InspectorField.InitializeChildProperties () (at ./Library/PackageCache/com.annulusgames.lucid-editor@3747d977e2/Editor/InspectorProperty/InspectorField.cs:80)
AnnulusGames.LucidTools.Editor.InspectorField..ctor (UnityEditor.SerializedProperty property, System.Attribute[] attributes) (at ./Library/PackageCache/com.annulusgames.lucid-editor@3747d977e2/Editor/InspectorProperty/InspectorField.cs:62)
AnnulusGames.LucidTools.Editor.InspectorPropertyUtil.CreateChildProperties (AnnulusGames.LucidTools.Editor.InspectorField property) (at ./Library/PackageCache/com.annulusgames.lucid-editor@3747d977e2/Editor/Utils/InspectorPropertyUtil.cs:49)
AnnulusGames.LucidTools.Editor.InspectorField.InitializeChildProperties () (at ./Library/PackageCache/com.annulusgames.lucid-editor@3747d977e2/Editor/InspectorProperty/InspectorField.cs:80)
AnnulusGames.LucidTools.Editor.InspectorField..ctor (UnityEditor.SerializedProperty property, System.Attribute[] attributes) (at ./Library/PackageCache/com.annulusgames.lucid-editor@3747d977e2/Editor/InspectorProperty/InspectorField.cs:62)
AnnulusGames.LucidTools.Editor.InspectorPropertyUtil.CreatePropertyField (UnityEditor.SerializedProperty serializedProperty) (at ./Library/PackageCache/com.annulusgames.lucid-editor@3747d977e2/Editor/Utils/InspectorPropertyUtil.cs:15)
AnnulusGames.LucidTools.Editor.InspectorPropertyUtil.CreateProperties (UnityEditor.SerializedObject serializedObject) (at ./Library/PackageCache/com.annulusgames.lucid-editor@3747d977e2/Editor/Utils/InspectorPropertyUtil.cs:26)
AnnulusGames.LucidTools.Editor.LucidEditor.InitializeProperties () (at ./Library/PackageCache/com.annulusgames.lucid-editor@3747d977e2/Editor/LucidEditor.cs:45)
AnnulusGames.LucidTools.Editor.LucidEditor.OnInspectorGUI () (at ./Library/PackageCache/com.annulusgames.lucid-editor@3747d977e2/Editor/LucidEditor.cs:30)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass72_0.<CreateInspectorElementUsingIMGUI>b__0 () (at <5909001d89834f35ba5cf7792a7cc442>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Nu99et commented 1 year ago

Not only nested class, nested struct, or just a indivisual serializable class or struct could cause this problem.