> For the complete documentation index, see [llms.txt](https://sunfish-studios.gitbook.io/main/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sunfish-studios.gitbook.io/main/secondary-components/fishing-ui-controller.md).

# Fishing UI Controller

<figure><img src="/files/7ziCU7VntwspU1g1XvOg" alt=""><figcaption></figcaption></figure>

A component that manages the display and animation of the “fish caught” UI panel. It receives [`FishData`](/main/main-components/fish-data.md), 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

<figure><img src="/files/NoCoxBXDQbidi7UNH26x" alt=""><figcaption></figcaption></figure>

**UI References**

* **Fish Caught Group**\
  `CanvasGroup` controlling the visibility and interactivity of the catch panel.
* **Fish Name Text**\
  `Text` element that displays the name of the caught fish.
* **Fish Weight Text**\
  `Text` element showing the randomized weight (formatted as “X.X kg”).
* **Fish Icon**\
  `Image` used to display the fish’s sprite (if provided in `FishData`).

**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

1. The fishing system calls `HandleFishDataReceived(fish)` with a valid `FishData` instance.
2. The controller updates the UI fields and waits for the **Open Panel Delay**.
3. It then fades in the panel over **Open Panel Duration**.
4. If **Auto Close** is enabled, it starts a timer and closes the panel after **Auto Close Time**.
5. At any point, external systems can force-close the panel via `HandleFishStateExit()` (e.g., when the player exits fishing).

<figure><img src="/files/yDh3JiF5MuPd2CjzUGz1" alt="" width="344"><figcaption></figcaption></figure>

The [**Fish Event Listener** ](/main/secondary-components/event-system.md)is used to respond to events and trigger the responses on **FishingUIController**.<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sunfish-studios.gitbook.io/main/secondary-components/fishing-ui-controller.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
