Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Feedback About PropertyAttributes that affect collections

Discussion in 'Unity 6 Beta' started by v0lt1369, Feb 28, 2024.

  1. v0lt1369


    May 1, 2020
    So for context, I am working on a unity package that adds some attributes to the inspector and I need some attributes to be able to affect the entire collection instead of just the members inside it, Unity 2023.3 allows that with the applyToCollection bool in the PropertyAttribute class, but there is a problem with that, I set applyToCollection to true and all the attributes worked perfectly on collections, but they stop working on regular members, I don't know if that's intended or its a bug but setting that property to true should not make it so the attribute only affects collections, for example I have a ShowField Attrbiute that shows or hides a field based on a condition, and I need when that is added to a collection to hide the entire collection instead of its members, so I set the applyToCollection property to true and works perfectly but then on regular fields that attribute does not work at all anymore, I need it to detect if the attached field is an array it will hide the entire array and if its a regular field it works like it normally would, and since the applyToCollection property its only a getter, I cant do a check if the field is an array or not and set it manually (besides that the drawer does not run at all if the field is not a collection), the only way to make this work is if I add an extra parameter to the attribute constructor to affect collections which its not very intuitive since that should not be a worry every time I use the attribute, it should just be detected automatically.