Hide field in list?

In the inspector, if you have a list of a class that has fields, the list will show all public fields right?

is it possible to hide certain values of a list conditionally?

for instance

I know in editor scripting, you can use a bool to hide fields, just not sure if or how its possible for the lists.

Example;

6739117--776428--ListExample1.png

6739117--776431--ListExample2.png

Try adding
[HideInInspector]
above your public class member.

[HideInInspector]
public string TestString;

I think you need a custom property inspector for this. It would just have code that checks the quantity and displays the sub-fields (or not). I think those work even when embedded in lists but I haven’t done it recently enough to be sure.

@PixelPrime11 That would permanently hide it.

@Kurt-Dekker I did make an inspector script for the TestList class and didn’t call the base OnGUI function, so none of the values would have shown up, but when in a List they do, so I imagine you’d have to do a custom property drawer for List, but how to do it as List. I’m not sure

Are you saying you made a custom property drawer for TestList class and it works as expected, but when you look at a collection of them it reverts to the default inspector for the TestList class?

That seems counter to my remembrance of it but it’s been a while.

@Kurt-Dekker
No, I made a custom inspector script for TestList and didn’t call base ongui, not a property drawer, but now that you say that, I think you’re right, make a property drawer for TestList.

The logic in my head was that the property being drawn was the list itself and thought I might have to make a custom list propertydrawer.

I’m gonna go play around with the Test List propertydrawer

1 Like

Pretty sure you just need a custom property drawer for TestList, or whatever the type the list contains. Then it will show up the way your property drawer dictates regardless of whether it’s part of a list or not.

1 Like