Hide
RequiredIf

Like Required, but only required if the condition is a truly result.

Parameters:

Arguments:

  • (Optional) EMode editorMode

    Condition: if it should be in edit mode, play mode for Editor or in some prefab stage. By default, (omitting this parameter) it does not check the mode at all.

    See Misc - EMode for more information.

  • object by...

    callbacks or attributes for the condition.

  • Allow Multiple: Yes

You can use multiple RequiredIf. The field will be required if ALL condition is true (and operation)

For multiple RequiredIf: The field will be required if ANY condition is true (or operation)

It also supports sub-field, and value comparison like ==, >, <=. Read more in the "Syntax for Show/Hide/Enable/Disable/Required-If" section.

You can use Required to change the notice message & icon. See the example below

using SaintsField; [Separator("Depende on other field or callback")] public GameObject go; [RequiredIf(nameof(go))] // if a field is a dependence of another field public GameObject requiredIfGo; public int intValue; [RequiredIf(nameof(intValue) + ">=", 0)] public GameObject requiredIfPositive; // if meet some condition; callback is also supported. [Separator("EMode condition")] [RequiredIf(EMode.InstanceInScene)] public GameObject sceneObj; // if it's a prefab in a scene [Separator("Suggestion")] // use as a notice public Transform hand; [RequiredIf(nameof(hand))] [Required("It's suggested to set this field if 'hand' is set", EMessageType.Info)] // this is now a config provider public GameObject suggestedIfHand; [Separator("And")] // You can also chain multiple conditions as "and" operation public GameObject andCondition; [RequiredIf(EMode.InstanceInScene, nameof(andCondition))] public GameObject instanceInSceneAndCondition; // if it's a prefab in a scene and 'andCondition' is set [Separator("Or")] // You can also chain multiple RequiredIf as "or" operation public GameObject orCondition; public int orValue; [RequiredIf(nameof(orCondition))] [RequiredIf(nameof(orValue) + ">=", 0)] public GameObject requiredOr; // if it's a prefab in a scene and 'andCondition' is set