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()→ getsTraitManager.GetTraitList(sliderPersonality), binds each entry to an existing childTraitNodeviaInit(trait), and caches the nodes.- Subscribes
UpdateUItoupdateTraitUI.
- OnEnable() → calls
UpdateUI()immediately. - OnDestroy() → unsubscribes the handler.
Fill Logic (UpdateUI)
Iterates nodes left → right keeping lastTraitCost (previous node’s required tokens):
- If
affinityTokens < lastTraitCost→SetAlphaMask(0)(hidden). - Else if
affinityTokens > node.requiredTokens→SetAlphaMask(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.