Your “LayoutComponentProperties” class is not a serializable class ^^. You can only make fields serializable of types which are serializable. Add the System.Serializable attribute to your class.
[System.Serializable]
public class LayoutComponentProperties
{
Also as you already figured out, what you have is not a field but a property. More specifically an auto-property that automatically creates a hidden private backing field. To make that hidden field serialized you have to use
[field:SerializeField]
public LayoutComponentProperties properties { get;set; }
Though just using a public field would be simpler:
I tried this before and it is still not working.My code looks like this.
Object
[Serializable]
public class LayoutComponentProperties
{
public LayoutComponentType type;
public RectTransform parent;
public LayoutComponentProperties(LayoutComponentType type, RectTransform parent)
{
this.type = type;
this.parent = parent;
}
}
Mono
public LayoutComponentProperties properties { get; set; }
Presumably you’ve also made the private field serializable too as suggested above? The mere fact than it can be serialized obviously doesn’t mean it will be if it’s private unless you ask for that.
Or is it public now? If so then yes, it should work as you suggest.
As mentioned above, that’s a property, not a field. The inspector doesn’t show properties. If you serialize the backing field for the property then it’ll show the field.
The inspector will do this but it has dedicated serialized properties you can use here for editor related stuff.