Useful Attributes
Last updated
Last updated
This attribute allows to make your class field visible or invisible in inspector depending on value of another field.
Add ConditionalHide attribute in the next format:
[ConditionalHide("conditionFieldName", hideInInspector, neededFieldValue)]
The first parameter (conditionFieldName) is the name of class field that will be checked.
If second parameter is true, your conditional field will be hidden from inspector in case if checked field value equals to neededFieldValue.
Otherwise, your field will be visible, but not editable in inspector.
In this case, secondField
will be visible in inspector only if firstField
value will be true.
Let's change the second parameter in ConditionalHide attribute and see what happens.
As result, we can always see secondField in inspector, but it can be editable or not:
This attribute makes class field not editable, but visible in inspector.
Add [ReadonlyField] attribute to your class field. Good job, that's all!