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.
ValueDeltaTypeRepresents the direction of change:
NEUTRALINCREASEDECREASEValueComparisonLineData model for one comparison row.
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.
ValueComparisonLineControllerUI Toolkit controller that renders a single ValueComparisonLine.
Features:
TooltipControllerusing 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);
}
}If you previously used item-specific stat line utilities:
ItemStatChangeType -> ValueDeltaTypeItemStatLine -> ValueComparisonLineItemStatLineController -> ValueComparisonLineControllerItemStatDataController 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)
Font Family
DM Sans
Wix
Inclusive Sans
AR One Sans
Direction