ValueComparison is a reusable utility for showing changes between two values in UI (old -> new), with optional increase/decrease coloring.

It is designed to be domain-agnostic: inventory, RPG stats, settings diffs, save slot comparisons, and more.

Types

ValueDeltaType

Represents the direction of change:

  • NEUTRAL
  • INCREASE
  • DECREASE

ValueComparisonLine

Data model for one comparison row.

csharp
public struct ValueComparisonLine { public string Key; public string Name; public Sprite Icon; public string OldValue; public string NewValue; public ValueDeltaType DeltaType; public bool HideOldValue; }

Use GetDeltaType(float value, float comparisonValue) to compute the delta state for numeric comparisons.

ValueComparisonLineController

UI Toolkit controller that renders a single ValueComparisonLine.

Features:

  • optional name and icon
  • old/new value presentation
  • arrow between values
  • delta-based color formatting for new value
  • optional tooltip support through TooltipController

Basic Usage

csharp
using CupkekGames.Luna; using UnityEngine; using UnityEngine.UIElements; public class ValueComparisonExample : MonoBehaviour { [SerializeField] private UIDocument _document; private void Start() { VisualElement root = _document.rootVisualElement; VisualElement host = root.Q<VisualElement>("ComparisonHost"); float oldValue = 12f; float newValue = 17f; ValueDeltaType delta = ValueComparisonLine.GetDeltaType(newValue, oldValue); var line = new ValueComparisonLine( key: "Damage", name: "Damage", icon: null, oldValue: oldValue.ToString(), newValue: newValue.ToString(), deltaType: delta, hideOldValue: false ); var controller = new ValueComparisonLineController(host, withName: true, withIcon: false); controller.SetData(line); } }

Migration Notes

If you previously used item-specific stat line utilities:

  • ItemStatChangeType -> ValueDeltaType
  • ItemStatLine -> ValueComparisonLine
  • ItemStatLineController -> ValueComparisonLineController

ItemStatDataController still lives in Inventory because it depends on ItemStatData, but now uses these generic value-comparison utilities internally.

Settings

Theme

Light

Contrast

Material

Dark

Dim

Material Dark

System

Sidebar(Light & Contrast only)

Light
Dark

Font Family

DM Sans

Wix

Inclusive Sans

AR One Sans

Direction

LTR
RTL