[Issue] ShowIf / EnableIf does not work with Arrays or Lists in nested classes
See original GitHub issue[ShowIf("ShowIfTest")]
public int[] test;
public bool ShowIfTest => false;
Here is the code I used to test it, no nesting.
It should be hidden, but no matter what, it will always show. Tried with List
as well.
I tried to search around current and past issues, but nothing came up on this issue. Is there any workaround for this issue, or did I miss the proper way to do this?
Thank you for all your work!
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
I have some trouble with nested class in Unity
Your last assignment makes no sense. First, the code is written as if Gift is a generic type, but that's not the Gift...
Read more >Array of class with nested classes populated at awake
I have come to an issue where I have an array of a class, with a nested single class inside that which I...
Read more >c# - When and why to use Nested Classes?
The main feature of nested classes is that they can access private members of the outer class while having the full power of...
Read more >Unity inspector foldout attribute. You switched accounts on an
Unity inspector foldout attribute. You switched accounts on another tab or window. TabGroup is used on any property, and organizes properties into different ......
Read more >Pybind template class. template <typename T> class py_sh
pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not very sure either how to fix it 😦
I guess for now, if you ever find some sort of workaround, let me know!! Would be very useful to have! Thank you so much for investigating the issue however, I really appreciate it 😃
I understood why it’s now working. Look at this example.
Even though I’ve marked the arrays with
[ReadOnly]
the property drawer is applied to each element of the arrays, not the arrays themselves. This is how Unity appliesCustomPropertyDrawers
to lists/arrays. This is what happens with the[AllowNesting]
attribute.[AllowNesting]
is a normal drawer, it just triggers the meta attributes’ behaviors (like[ShowIf]
for instance). The problem is that NaughtyAttributes triggers the behaviors before the actual drawer is called. The drawer can’t handle the visibility itself, because the parent property is already drawn. I can make it handle the visibility itself, but the result will be just like the[ReadOnly]
attribute. The array will be visible, only the child elements will not.The reason why the
[ShowIf]
works for not nested arrays is that I can get the array and say to Unity - “draw the property and its children”. Before I draw the property and its children, I check if it is visible. If it’s not I don’t draw it at all.I can’t think of a way to fix it 😦