Version 3.3.0.1

Odin has a dedicated attribute overview with examples

PropertyOrderAttribute 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)]
[Conditional("UNITY_EDITOR")]
public class PropertyOrderAttribute : Attribute, _Attribute

PropertyOrder is used on any property, and allows for ordering of properties.

Use this to define in which order your properties are shown.

Inheritance
  • System.Object
  • System.Attribute
  • PropertyOrderAttribute
Remarks

Lower order values will be drawn before higher values.

note

There is unfortunately no way of ensuring that properties are in the same order, as they appear in your class. PropertyOrder overcomes this.

Example

The following example shows how PropertyOrder is used to order properties in the inspector.

public class MyComponent : MonoBehaviour
{
	[PropertyOrder(1)]
	public int MySecondProperty;

	[PropertyOrder(-1)]
	public int MyFirstProperty;
}

Constructors

PropertyOrderAttribute()
Initializes a new instance of the PropertyOrderAttribute class.
public PropertyOrderAttribute()
PropertyOrderAttribute(Single)
Defines a custom order for the property.
public PropertyOrderAttribute(float order)
Parameters
System.Single order

The order for the property.

Fields

Order
The order for the property.
public float Order