Meta Attributes

https://odininspector.com/tutorials/using-attributes/meta-attributes

[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;
	}
}

[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;
	}
}

Last updated