SuperBehaviour SuperBehaviour
SuperBehaviour SuperBehaviour
v0.1.2 [Beta]

Search Results for

    Class ShowIfAttribute

    Namespace
    LoM.Super
    Assembly
    LoM.Super.dll

    Attribute to show or hide a field based on a condition.
    Note: If the target field is a bool it will check for true/false, otherwise it will check if the field is not null.


    [SerializeField] private bool m_UseFeature;
    [SerializeField, ShowIf("m_UseFeature")] private Transform m_ObjectReference; // Will only be visible if m_UseFeature is true.

    [AttributeUsage(AttributeTargets.Property|AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
    public class ShowIfAttribute : ConditionAttribute
    Inheritance
    object
    Attribute
    ConditionAttribute
    ShowIfAttribute
    Derived
    EditableIfAttribute

    Constructors

    ShowIfAttribute(string, bool)

    Attribute to show or hide a field based on a condition. (shown if condition is true)

    public ShowIfAttribute(string fieldName, bool value = true)

    Parameters

    fieldName string

    The name of the field to check.

    value bool

    The value to check for.

    ShowIfAttribute(string, int, bool)

    Attribute to show or hide a field based on a condition. (shown if condition is true) [Enum]


    [SerializeField]
    private SomeEnum m_Enum;
    [SerializeField, ShowIf(nameof(m_Enum), (int)SomeEnum.Option2)]
    private Transform m_ObjectReference; // Will only be visible if m_Enum is Option2.

    public ShowIfAttribute(string fieldName, int enumValue, bool isEqualTo = true)

    Parameters

    fieldName string

    The name of the field to check.

    enumValue int

    The enum value to check for (as an int).

    isEqualTo bool

    If the field should be visible if the enum value is equal or inequal to the provided value.

    Properties

    EnumValue

    public int EnumValue { get; }

    Property Value

    int

    FieldName

    public string FieldName { get; }

    Property Value

    string

    Value

    public bool Value { get; }

    Property Value

    bool

    Methods

    EvaluateActive(object)

    Override this method to calculate if the field is active or not.

    public override bool EvaluateActive(object target)

    Parameters

    target object

    The object to evaluate the condition for.

    Returns

    bool

    True if the field is active; otherwise false.

    EvaluateReadOnly(object)

    Override this method to calculate if the field is read only or not.

    public override bool EvaluateReadOnly(object target)

    Parameters

    target object

    The object to evaluate the condition for.

    Returns

    bool

    True if the field is read only; otherwise false.

    © Lords of Mahlstrom Gaming, all rights reserved.