Namespace: | Sirenix.OdinInspector |
Assembly: | Sirenix.OdinInspector.Attributes |
[DontApplyToListElements]
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = true, Inherited = true)]
public sealed class DisableIfAttribute : Attribute, _Attribute
DisableIf is used on any property, and can disable or enable the property in the inspector.
Use this to disable properties when they are irrelevant.
The following example shows how a property can be disabled by the state of a field.
public class MyComponent : MonoBehaviour
{
public bool DisableProperty;
[DisableIf("DisableProperty")]
public int MyInt;
public SomeEnum SomeEnumField;
[DisableIf("SomeEnumField", SomeEnum.SomeEnumMember)]
public string SomeString;
}
The following examples show how a property can be disabled by a function.
public class MyComponent : MonoBehaviour
{
[EnableIf("MyDisableFunction")]
public int MyInt;
private bool MyDisableFunction()
{
// ...
}
}
public DisableIfAttribute(string memberName)
System.String | memberName | Name of member bool field, property, or method. |
public DisableIfAttribute(string memberName, object optionalValue)
System.String | memberName | Name of member to check value of. |
System.Object | optionalValue | Value to check against. |
public string MemberName
public object Value