I think the idea behind PropertyCollectionAttribute is great. Being able to use attribute property drawers on collections has been a long requested feature!
However the current implementation using PropertyCollectionAttribute
has some serious usage issues. It requires you to have separate attributes and drawers for collections. So you would need to make your own CollectionHeader
and CollectionSpace
attributes, and when making custom attributes like a ReadOnly
, you would also need a CollectionReadOnly
, and do this for every attribute. This makes it more complicated to create attribute drawers and doubles the number of attributes and drawers you need to write and users need to use/remember.
After looking at the code, it looks like simply adding a bool property like applyToCollection
to PropertyAttribute
would solve both issues. The bool would allow existing attributes to just automatically work with collections, would be less code to maintain for Unity, and fewer APIs. And would not require developers to write two attributes and drawers for everything.
And since the attribute is passed to the PropertyDrawer
, we can still have collection specific implementations by simply checking the bool of the attribute from within the drawer
The only usecase this does not cover is if you wanted a attribute to only apply to a collection and nothing else. But, to me that feels like it falls under the same sort of situation as things like the Range, and Min attributes. Which only can be applied to float and integer fields. Additionally, the bool could be virtual, so you can override it. Or even add a second get only bool property that can be overridden to determine if it is collection only.
Thank you!