Skip to content

🎨 Presentation (Rarity)

Handles how items look in UI by mapping rarity values to display names and colors.

🎨 Visual layer only — no gameplay logic
💡 Swappable at runtime for instant reskinning
✅ Fully optional — defaults to plain text + white color


Purpose

Provide a clean abstraction for translating numeric rarity values into user-facing presentation — names, colors, and labels — used across grids, tooltips, badges, and debug panels.

This layer is intentionally decoupled from gameplay logic.


Contents

File Purpose
RarityTheme Abstract ScriptableObject defining GetName and GetColor.
DefaultRarityTheme Built-in implementation with common tiers (Common → Legendary).
RarityThemeUtil Static helpers for null-safe access to rarity name/color.

🚀 Quick Start

  1. Create asset: Create > RevFramework > Inventory > Rarity Theme (Default)
  2. Edit steps: map rarity integers → display name + color
  3. Assign: reference the theme in your UI (e.g. inventory grids, tooltips, debug panels)
var theme = myRarityTheme;
string label = RarityThemeUtil.Name(theme, rarity);
Color color = RarityThemeUtil.ColorOf(theme, rarity);

🧩 RarityTheme

Abstract base class:

public abstract class RarityTheme : ScriptableObject
{
    public abstract string GetName(int rarity);
    public abstract Color GetColor(int rarity);
}

Create subclasses if your project requires dynamic, procedural, or rule-driven rarity presentation.


🎨 DefaultRarityTheme

Provides a serialized list of rarity mappings:

[System.Serializable]
public struct Step
{
    public int rarity;
    public string name;
    public Color color;
}

Behaviour:

  • Any number of steps may be defined
  • Order does not matter
  • If no step matches:
  • Name falls back to "R{rarity}"
  • Color falls back to Color.white

✨ Utilities

RarityThemeUtil provides static, null-safe helpers:

var label = RarityThemeUtil.Name(theme, rarity);
var color = RarityThemeUtil.ColorOf(theme, rarity);

These helpers: - Never throw
- Work when theme == null
- Are ideal for UI code paths


⚠️ Notes & Gotchas

  • Rarity values are plain integers — ensure your project uses a consistent scale
  • Theme optional: when no theme is assigned, UI falls back to neutral output
  • Runtime swapping: themes can be hot-swapped for instant visual restyling

  • DataItemDefinition.rarity field
  • UI → grids and tooltips consuming rarity presentation