Version 2.1.0.0

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)]
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(Int32)
Defines a custom order for the property.
public PropertyOrderAttribute(int order)
Parameters
System.Int32 order

The order for the property.

Fields

Order
The order for the property.
public int Order

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.