Odin has a dedicated attribute overview with examples

EnableIfAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[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 EnableIfAttribute : Attribute, _Attribute

EnableIf is used on any property, and can enable or disable the property in the inspector.

Use this to enable properties when they are relevant.

  • System.Object
  • System.Attribute
  • EnableIfAttribute

The following example shows how a property can be enabled by the state of a field.

public class MyComponent : MonoBehaviour
	public bool EnableProperty;

	public int MyInt;

    public SomeEnum SomeEnumField;

	[EnableIf("SomeEnumField", SomeEnum.SomeEnumMember)]
	public string SomeString;

The following examples show how a property can be enabled by a function.

public class MyComponent : MonoBehaviour
	public int MyInt;

	private bool MyEnableFunction()
		// ...


Enables a property in the inspector, based on the state of a member.
public EnableIfAttribute(string memberName)
System.String memberName

Name of member bool field, property, or method.

EnableIfAttribute(String, Object)
Enables a property in the inspector, if the specified member returns the specified value.
public EnableIfAttribute(string memberName, object optionalValue)
System.String memberName

Name of member to check value of.

System.Object optionalValue

Value to check against.


The name of a bool member field, property or method.
public string MemberName
The optional member value.
public object Value

This website is brand new and built with the Odin 2.1 beta in mind. This means you might discover some features such as attribute expressions that are only available in the beta.

You can download the 2.1 beta from here and read the patch-notes here.