Odin property drawer hides serialized fields on IList implementation.
Issue #832
new
What happened?
I created a class that I want to derive from and serialize in Unity:
Container<T> : IList<T>, IReadOnlyList<T> where T : Component
it has the following serialized fields:
[SerializeField]
private T itemPrefab;
[SerializeField]
protected Transform transform;
[SerializeField]
protected List<T> items = new List<T>();
The default property drawer shows all of them and I can modify the object without a problem.
When I enable Odin in inspector the property drawer now only displays a list collection. I can’t modify itemPrefab
or transform
fields.
How can we reproduce it?
I attached the Container script, create a new class that derives from it and inspect its property drawer.
What version of Unity are you using?
2019.4.34f1
What version of Odin are you using? (See "Tools > Odin Inspector > About")
3.0.12.0
Do you have Editor Only mode enabled?
Yes
I got kind of the same problem.
I have List<Extended Class Type> and the element the listitem actually is protected in the base class.
This also caused the list, when elements are added, to only show with a height of like 5px and no content (except for the delete X button)
The workaround for the issue is to make the element the list contains from the base class not protected but public.
A fix would be of course to manage that protected stuff is handeled properly.
Here some simplified code of my classes and stuff: