CoinDrawer

Odin Inspector value drawer for Coin fields. Renders coin values as three inline integer fields with colored denomination icons (gold, silver, copper) instead of a single raw int.

Definition

Namespace: Paragon.Townskeep Assembly: Townskeep.Editor.dll

[DrawerPriority(0.0, 0.0, 3000.0), UsedImplicitly]
public class CoinDrawer : OdinValueDrawer<Coin>

Inheritance: OdinValueDrawer<Coin> → CoinDrawer

Remarks

CoinDrawer uses a high priority (3000.0) to ensure it overrides any default drawer for Coin fields. It renders a horizontal layout with:

  1. The property label (via DrawGUI.PrefixLabel)

  2. Three integer fields using EditorGUI.MultiIntField with colored circle icons:

    • Gold — yellow (#FFCC00)

    • Silver — grey-blue (#808099)

    • Copper — brown (#B3662A)

Icon textures are lazily created via SdfIcons.CreateTransparentIconTexture() and cached in a static array for reuse across all CoinDrawer instances.

When the user edits any denomination, the drawer recomputes the raw value (gold * 10000 + silver * 100 + copper), calls SetValue() on the Coin, and marks the serialization root dirty.

circle-info

The drawer uses DrawGUI.HorizontalLayout() from Paragon.Editor for consistent horizontal layout rendering.

Quick Lookup

Goal
How

Apply to a Coin field

Automatic — drawer is registered via Odin at priority 3000

Customise icon colors

Modify GetCoinIcons() static method

Methods

DrawPropertyLayout (override)

Renders the Coin property as three inline denomination fields.

Parameter
Type
Description

label

GUIContent

The property label from Odin

Rendering pipeline:

  1. Begin horizontal layout

  2. Draw prefix label

  3. Read current Gold/Silver/Copper values from ValueEntry.SmartValue

  4. Render EditorGUI.MultiIntField with coin icons

  5. On change: recompute raw value, call SetValue(), mark dirty

GetCoinIcons (static, private)

Lazily creates and caches the three denomination icon textures.

Returns: Array of 3 GUIContent entries with colored circle icons.

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

  • Coin — the type this drawer renders

  • Currency — abstract base record

Last updated