Version 2.1.0.0

Odin has a dedicated attribute overview with examples

PropertySpaceAttribute 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)]
[DontApplyToListElements]
public class PropertySpaceAttribute : Attribute, _Attribute

The PropertySpace attribute have the same function as Unity's existing Space attribute, but can be applied anywhere as opposed to just fields.

Inheritance
  • System.Object
  • System.Attribute
  • PropertySpaceAttribute
Example

The following example demonstrates the usage of the PropertySpace attribute.

[PropertySpace] // Defaults to a space of 8 pixels just like Unity's Space attribute.
public int MyField;

[ShowInInspector, PropertySpace(16)]
public int MyProperty { get; set; }

[ShowInInspector, PropertySpace(16, 16)]
public int MyProperty { get; set; }

[Button, PropertySpace(32)]
public void MyMethod()
{
    ...
}

[PropertySpace(-8)] // A negative space can also be remove existing space between properties.
public int MovedUp;

Constructors

PropertySpaceAttribute()
Adds a space of 8 pixels between properties.
public PropertySpaceAttribute()
PropertySpaceAttribute(Single)
Adds a space between properties.
public PropertySpaceAttribute(float spaceBefore)
Parameters
System.Single spaceBefore

PropertySpaceAttribute(Single, Single)
Adds a space between properties.
public PropertySpaceAttribute(float spaceBefore, float spaceAfter)
Parameters
System.Single spaceBefore

System.Single spaceAfter

Fields

SpaceAfter
The space between properties in pixels.
public float SpaceAfter
SpaceBefore
The space between properties in pixels.
public float SpaceBefore