PatronSelectorUI
Overview
Picker that cycles through a grid of Patron portraits stored in Resources/Patrons/…. Animates the previous image out and the next image in with fade & slide, and offsets the index by the currently selected personality to show the matching portrait variant.
Serialized
- IntVariable
selectedPatron,selectedPersonality - GameObject
patronPrefab(contains anImage) - Button
leftButton,rightButton - Transform
patronImagesParent
Behavior
- Start()
LoadPatrons()→Resources.LoadAll<Sprite>(patronDataPath)then instantiates one prefab per sprite underpatronImagesParent.- Registers
OnPersonalityChanged()to animate the previous and current images when personality changes.
- OnLeftButtonPressed() / OnRightButtonPressed()
- Guard against double-taps while tweens with a
_busyflag and a shared tween id. - Slides/fades the current image out, updates
selectedPatronby ±3 (wrap-around), and brings the next image in to the focus position.
- Guard against double-taps while tweens with a
- SafeIndex(int i) wraps indexes for any list length.
public static string patronDataPath = "Patrons\\"; (ensure sprites are in this folder).