Meta Attributes


Some attributes don't do anything as tangible as changing how, where or when a value is drawn. Instead, they're more reactive in nature, and add some basic intelligence to the inspector. They allow you to perform more complicated tasks like validating input, invoking a method when a value is changed, and many other such things.

[ValidateInput("IsValid")]
public int GreaterThanZero;

private bool IsValid(int value)
{
	return value > 0;
}

[OnValueChanged("UpdateRigidbodyReference")]
public GameObject Prefab;

private Rigidbody prefabRigidbody;

private void UpdateRigidbodyReference()
{
	if (this.Prefab != null)
	{
		this.prefabRigidbody = this.Prefab.GetComponent<Rigidbody>();
	}
	else
	{
		this.prefabRigidbody = null;
	}
}

Using such meta attributes, any programmer has a powerful, easy-to-use suite of tools available to help enforce necessary rules, as well as assist, constrain and guide the designers that use the inspector by providing feedback, relevant information and tooltips at the right times, resulting in an overall smoother workflow, less prone to errors and mistakes.

[Required]
public GameObject RequiredReference;

[InfoBox("This message is only shown when MyInt is even", "IsEven")]
public int MyInt;

private bool IsEven()
{
	return this.MyInt % 2 == 0;
}

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.