Skip to content

Decorators

Ilia Petrov-Komotskii edited this page Sep 29, 2026 · 9 revisions

A decorator draws around a field. It does not replace the control. Unity runs every DecoratorDrawer on the field, so you can stack them on top of one Property Drawers.

That is the useful part. One field can carry a message, a prefix, a postfix, a read-only lock, and an availability rule at the same time, and still use DropdownList or LayerSelector for the value itself. You can extend this combination yourself.

[InfoBox("Important message about the field.")]
[Postfix(" (s.)")]
[AvailableIf(nameof(_featureEnabled), invert: true)]
[SerializeField] private float duration;

While _featureEnabled is false, the field stays editable. Turn it on and the field is disabled. The message and the postfix stay either way. ReadOnly can join the same stack; it always draws the field disabled and blocks paste.

All of these attributes are in Mane.Unity. They work with or without ManeStyle.

InfoBox and Postfix on the same component

InfoBox

Message above the field. An optional bool field, property, or parameterless method controls visibility.

Default polarity: the box is shown when that bool is false (the most common case: a warning you hide once the condition is met). invertCondition: true shows it when the bool is true. If the member is missing, the box stays visible and the Console gets a warning.

Types: Info, Warning, Error, None.

On a collection the box belongs to the collection, not to each element.

[InfoBox("Assign a prefab or this will spawn nothing.", InfoBoxType.Warning, nameof(IsAssigned))]
[SerializeField] private GameObject prefab;

private bool IsAssigned => prefab != null;

InfoBox example

ReadOnly

The field is drawn disabled. Editing is blocked, but you can copy the value.

[SerializeField, ReadOnly] private float computedHealth;

ReadOnly example

Prefix / Postfix

Text immediately before or after the value. Use both on the same field.

On a list or array they rewrite the collection title (prefix + label + postfix). They do not stamp each element.

[Prefix("in "), Postfix(" (s.)")]
[SerializeField] private float startTime;

[Postfix(" (coins)")]
[SerializeField] private int[] prices;

Prefix / Postfix example

AvailableIf

Enable, disable (read only), or hide a field.

  • Availability provider: bool field, property, or parameterless method. A sibling serialized property also works; any non-default value counts as true (so a bool must be true, a number non-zero, an object assigned).
  • invert flips the resolved value.
  • hide: true hides instead of disabling.
[SerializeField] private bool useCustomRadius;

[AvailableIf(nameof(useCustomRadius), hide: true)]
[SerializeField] private float customRadius;

Clone this wiki locally