EnableIfAttribute

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.

namespace Sirenix.OdinInspector
{
[DontApplyToListElementsAttribute]
[AttributeUsageAttribute((AttributeTargets)448, AllowMultiple = True, Inherited = True)]
public sealed class EnableIfAttribute : Attribute
}

Requirements

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector
Version: 1.0.4.1

See Also

Constructors

Definition Description
EnableIfAttribute(string) Enables a property in the inspector, based on the state of a member.

Properties

Return Type Definition Description
string MemberName The name of a bool member field, property or method.

Example

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

public class MyComponent : MonoBehaviour
{
	public bool EnableProperty;

	[EnableIf("EnableProperty")]
	public int MyInt;
}

Example

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

public class MyComponent : MonoBehaviour
{
	[EnableIf("MyEnableFunction")]
	public int MyInt;

	private bool MyEnableFunction()
	{
		// ...
	}
}