HideIfAttribute

HideIf is used on any property and can hide the property in the inspector.

Use this to hide irrelevant properties based on the current state of the object.

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

Requirements

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector
Version: 1.0.5.0

See Also

Constructors

Definition Description
HideIfAttribute(string, bool) Initializes a new instance of the HideIfAttribute class.

Properties

Return Type Definition Description
bool Animate Whether or not to slide the property in and out when the state changes.
string MemberName Name of a bool field, property or function to show or hide the property.

Example

This example shows a component with fields hidden by the state of another field.

public class MyComponent : MonoBehaviour
{
	public bool ShowProperties;

	[HideIf("showProperties")]
	public int MyInt;

	[HideIf("showProperties")]
	public string MyString;
}

Example

This example shows a component with a field that is hidden when the game object is inactive.

public class MyComponent : MonoBehaviour
{
	[HideIf("MyVisibleFunction")]
	public int MyHideableField;

	private bool MyVisibleFunction()
	{
		return this.gameObject.activeInHierarchy;
	}
}