Home > Back-end >  Show field based on multiple enum values - Odin
Show field based on multiple enum values - Odin

Time:02-12

I want to Show the field in UnityInspector based on specific enum field.

Lets say this is the enum class

  public enum Mode
    {
        None,
        Movement,
        Rotation,
        Scale
    }

I want to enable this field if "Movement or Scale" is selected from the enum dropdown, otherwise hide the field.

        public Vector3 NewValues;

With Odin I can do:

    [ShowIf("tweenMode", TweenMode.Movement)]
    public Vector3 NewValues;

But that will work only on Movement enum. Any idea on how to make it work on multiple enums? Thanks

CodePudding user response:

Afaik you can simply do something like

private bool showNewValues => tweenMode == TweenMode.Movement || tweenMode == TweenMode.Rotation;

[ShowIf(nameof(showNewValues))]
public Vector3 NewValues;

See ShowIf

  • Related