TraitSliderUI

Overview

Builds a horizontal trait slider from the trait list of a given personality and renders a progressive fill across its nodes based on the current affinity tokens.

Serialized

  • VoidEvent updateTraitUI — refresh trigger.
  • FloatVariable affinityTokens — how many tokens the player currently has.
  • GameManager.ChairmanPersonalities sliderPersonality — which personality’s trait list to display.

Lifecycle

  • Awake()
    • Init() → gets TraitManager.GetTraitList(sliderPersonality), binds each entry to an existing child TraitNode via Init(trait), and caches the nodes.
    • Subscribes UpdateUI to updateTraitUI.
  • OnEnable() → calls UpdateUI() immediately.
  • OnDestroy() → unsubscribes the handler.

Fill Logic (UpdateUI)

Iterates nodes left → right keeping lastTraitCost (previous node’s required tokens):

  • If affinityTokens < lastTraitCostSetAlphaMask(0) (hidden).
  • Else if affinityTokens > node.requiredTokensSetAlphaMask(1) (fully shown).
  • Else → partial fill:
    SetAlphaMask((affinityTokens - lastTraitCost) / (node.requiredTokens - lastTraitCost)).

This produces a smooth fill that advances from one node to the next as tokens accumulate.