Scripting / UI
Window
Abstract base class for all modal UI panels. Handles show/hide by toggling the GameObject and plays optional open/close sound effects. Subclass it to create any new panel in the scene.
Inspector Fields
| Field | Type | Description |
|---|---|---|
audioSource | AudioSource | AudioSource used to play the open and close sound clips. If left empty the window opens and closes silently. |
openSound | AudioClip | Clip played when Open() is called. |
closeSound | AudioClip | Clip played when Close() is called. |
Methods
| Method | Description |
|---|---|
Open() | Sets the GameObject active and plays openSound. Virtual — override to run custom logic before or after showing. |
Close() | Sets the GameObject inactive and plays closeSound. Virtual — override to run custom logic before or after hiding. |
Subclassing Window
Inherit from Window and override the virtual methods to add behaviour. Always call base.Open() or base.Close() to keep the GameObject toggle and audio working.
public class MyPanel : Window
{
public override void Open()
{
// populate the panel before it appears
Refresh();
base.Open();
}
public override void Close()
{
base.Close();
// clean up after the panel hides
OnClosed?.Invoke();
}
}
Built-in subclasses in the project: InventoryWindow, WinScreenController, GameOptionsMenu, ItemsListWindow. See UI Setup for placement and Inspector configuration guidance.