DisableIfAttribute

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.

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

Requirements

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

See Also

Constructors

Definition Description
DisableIfAttribute(string) Disables 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 disabled by the state of a field.

public class MyComponent : MonoBehaviour
{
	public bool DisableProperty;

	[DisableIf("DisableProperty")]
	public int MyInt;
}

Example

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()
	{
		// ...
	}
}