ReadOnlyAttribute

ReadOnly is used on any property, and disabled the property from being changed in the inspector.

Use this for when you want to see the value of a property in the inspector, but don't want it to be changed.

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

Requirements

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

See Also

Example

The following example shows how a field can be displayed in the editor, but not be editable.

public class Health : MonoBehaviour
{
	public int MaxHealth;

	[ReadOnly]
	public int CurrentHealth;
}

Example

ReadOnly can also be combined with ShowInInspectorAttribute.

public class Health : MonoBehaviour
{
	public int MaxHealth;

	[ShowInInspector, ReadOnly]
	private int currentHealth;
}