Version 3.3.0.1

Odin has a dedicated attribute overview with examples

SuffixLabelAttribute 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 = true, Inherited = false)]
[Conditional("UNITY_EDITOR")]
public sealed class SuffixLabelAttribute : Attribute, _Attribute

The SuffixLabel attribute draws a label at the end of a property.

Use this for conveying intend about a property. Is the distance measured in meters, kilometers, or in light years?. Is the angle measured in degrees or radians? Using SuffixLabel, you can place a neat label at the end of a property, to clearly show how the the property is used.

Inheritance
  • System.Object
  • System.Attribute
  • SuffixLabelAttribute
Example

The following example demonstrates how SuffixLabel is used.

public class MyComponent : MonoBehaviour
{
	// The SuffixLabel attribute draws a label at the end of a property.
	// It's useful for conveying intend about a property.
	// Fx, this field is supposed to have a prefab assigned.
	[SuffixLabel("Prefab")]
	public GameObject GameObject;

	// Using the Overlay property, the suffix label will be drawn on top of the property instead of behind it.
	// Use this for a neat inline look.
	[SuffixLabel("ms", Overlay = true)]
	public float Speed;

	[SuffixLabel("radians", Overlay = true)]
	public float Angle;

	// The SuffixLabel attribute also supports string member references by using $.
	[SuffixLabel("$Suffix", Overlay = true)]
	public string Suffix = "Dynamic suffix label";
}

Constructors

SuffixLabelAttribute(SdfIconType)
Draws a label at the end of the property.
public SuffixLabelAttribute(SdfIconType icon)
Parameters
SdfIconType icon

The icon to be displayed.

SuffixLabelAttribute(String, SdfIconType, Boolean)
Draws a label at the end of the property.
public SuffixLabelAttribute(string label, SdfIconType icon, bool overlay = false)
Parameters
System.String label

The text of the label.

SdfIconType icon

The icon to be displayed.

System.Boolean overlay

If true the suffix label will be drawn on top of the property, instead of after.

SuffixLabelAttribute(String, Boolean)
Draws a label at the end of the property.
public SuffixLabelAttribute(string label, bool overlay = false)
Parameters
System.String label

The text of the label.

System.Boolean overlay

If true the suffix label will be drawn on top of the property, instead of after.

Fields

IconColor
Supports a variety of color formats, including named colors (e.g. "red", "orange", "green", "blue"), hex codes (e.g. "#FF0000" and "#FF0000FF"), and RGBA (e.g. "RGBA(1,1,1,1)") or RGB (e.g. "RGB(1,1,1)"), including Odin attribute expressions (e.g "@this.MyColor"). Here are the available named colors: black, blue, clear, cyan, gray, green, grey, magenta, orange, purple, red, transparent, transparentBlack, transparentWhite, white, yellow, lightblue, lightcyan, lightgray, lightgreen, lightgrey, lightmagenta, lightorange, lightpurple, lightred, lightyellow, darkblue, darkcyan, darkgray, darkgreen, darkgrey, darkmagenta, darkorange, darkpurple, darkred, darkyellow.
public string IconColor
Label
The label displayed at the end of the property.
public string Label
Overlay
If true the suffix label will be drawn on top of the property, instead of after.
public bool Overlay

Properties

HasDefinedIcon
public bool HasDefinedIcon { get; }
Icon
The icon to be displayed.
public SdfIconType Icon { get; set; }