Version 2.1.11

Odin has a dedicated attribute overview with examples

ReadOnlyAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = false, Inherited = true)]
public sealed class ReadOnlyAttribute : Attribute, _Attribute

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.

  • System.Object
  • System.Attribute
  • ReadOnlyAttribute


This attribute only affects the inspector! Values can still be changed by script.


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

public class Health : MonoBehaviour
	public int MaxHealth;

	public int CurrentHealth;

ReadOnly can also be combined with ShowInInspectorAttribute.

public class Health : MonoBehaviour
	public int MaxHealth;

	[ShowInInspector, ReadOnly]
	private int currentHealth;


public ReadOnlyAttribute()