- changed title to Feature Request: Add "*If" variants of validation attributes
- edited description
Feature Request: Add "*If" variants of validation attributes
I frequently find myself adding public fields that are only required when certain other conditions are met. For example, some public boolean field toggles which of two Transform fields is shown via ShowIf
. Those Transform fields should be required when they are shown, otherwise not. To this end, a RequiredIf
attribute would be very helpful so that project validation works as expected. Having *If
variants of the other validation attributes (such as Range
) would be helpful for the same reasons…only validating public fields when they are “relevant”.
- Unity version: 2021.2.2f1
- Odin version: 3.0.12.0
- Editor Only mode: enabled
- OS: Windows 11 Pro
Comments (6)
-
reporter -
reporter - changed version to 3.0.12.0
- edited description
-
I just faced a base class where some of the child classes do not require a field. This would be covered nicely by this feature request.
-
+1 for required if
I often show and hide members based on bool toggles or other fields being filled in, a RequiredIf attribute would be very beneficial.
Is there a way of achieving this with custom attribute scripting?
-
+1. We do a lot of “ShowIf(“SomeBool”)” to keep the inspector nice. Being able to use Required in the validator but also tied to the same bool would be huge. Even if this has to be a custom script, its something that would add a lot of value to the validator with the way our project is setup.
-
You can achieve this by using the ValidateInput attribute instead.
- Log in to comment