🖼️Fishing UI Controller

A component that manages the display and animation of the “fish caught” UI panel. It receives FishData, updates visual elements (name, weight, icon), and handles smooth fade-in/fade-out animations with optional auto-close behavior.
This is a example on how to integrate Fish Data in your other systems.
🔧 Inspector Settings

UI References
Fish Caught Group
CanvasGroupcontrolling the visibility and interactivity of the catch panel.Fish Name Text
Textelement that displays the name of the caught fish.Fish Weight Text
Textelement showing the randomized weight (formatted as “X.X kg”).Fish Icon
Imageused to display the fish’s sprite (if provided inFishData).
Panel Settings
Open Panel Delay Time (in seconds) to wait after a fish is caught before starting the panel fade-in.
Open Panel Duration Duration of the fade-in animation when the panel appears.
Close Panel Duration Duration of the fade-out animation when the panel disappears.
Auto Close If enabled, the panel will automatically close after a set time.
Auto Close Time (visible only if Auto Close is enabled) How long (in seconds) the panel remains open before auto-closing.
💡 Key Features
Event-Driven: Fires static events (
OnFishDisplayed,OnPanelOpened,OnPanelClosed) for integration with other systems (e.g., achievements, journals, sound effects).Safe Initialization: Validates required UI references on startup and logs warnings/errors if missing.
Animation Control: Prevents overlapping animations and allows forced closure (e.g., when exiting the fishing state).
Editor Testing: Includes context menu options in the Unity Editor to test open/close behavior at runtime.
🎯 Usage Flow
The fishing system calls
HandleFishDataReceived(fish)with a validFishDatainstance.The controller updates the UI fields and waits for the Open Panel Delay.
It then fades in the panel over Open Panel Duration.
If Auto Close is enabled, it starts a timer and closes the panel after Auto Close Time.
At any point, external systems can force-close the panel via
HandleFishStateExit()(e.g., when the player exits fishing).

The Fish Event Listener is used to respond to events and trigger the responses on FishingUIController.
Last updated