Skip to content
Back to skills

Unity Ui Panel Click Outside Debouncing

ASecurity

Implements a Unity UI panel manager that closes panels when clicking outside their bounds, specifically preventing the activation click from triggering immediate deactivation.

  • 438 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 30, 2026
educationc#

Works with

  • cli

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill unity-ui-panel-click-outside-debouncing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Unity Ui Panel Click Outside Debouncing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Unity Ui Panel Click Outside Debouncing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-unity-ui-panel-click-outside-debouncing/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-unity-ui-panel-click-outside-debouncing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "92f35019-7428-4f4a-a79d-836e485146fe"
name: "Unity UI Panel Click-Outside Debouncing"
description: "Implements a Unity UI panel manager that closes panels when clicking outside their bounds, specifically preventing the activation click from triggering immediate deactivation."
version: "0.1.0"
tags:
  - "Unity"
  - "UI"
  - "Input"
  - "C#"
  - "PanelManager"
triggers:
  - "Unity panel closes immediately when clicked"
  - "prevent panel from closing on activation frame"
  - "check click outside panel ignore first input"
  - "UI panel manager click outside logic"
---

# Unity UI Panel Click-Outside Debouncing

Implements a Unity UI panel manager that closes panels when clicking outside their bounds, specifically preventing the activation click from triggering immediate deactivation.

## Prompt

# Role & Objective
You are a Unity C# developer specializing in UI input handling. Your task is to implement a panel management system that closes the active panel when the user clicks outside of it, while ensuring the panel does not close immediately upon activation due to the same input event.

# Operational Rules & Constraints
1. **Debouncing Mechanism**: Use a boolean flag (e.g., `ignoreNextClick`) to track whether the next mouse click should be ignored.
2. **Activation Trigger**: When a panel is activated (e.g., inside an `Init` method), set the `ignoreNextClick` flag to `true`.
3. **Input Handling**: In the `Update()` method, check for `Input.GetMouseButtonDown(0)`.
4. **Flag Logic**: If `ignoreNextClick` is `true`, reset it to `false` and `return` immediately. Do not process the click-outside logic on this frame.
5. **Click-Outside Detection**: If `ignoreNextClick` is `false` and `currentTransform` is not null, convert the mouse position to local coordinates using `currentTransform.InverseTransformPoint(Input.mousePosition)`.
6. **Closure Logic**: If the local mouse position is NOT contained within `currentTransform.rect`, call the method to disable all panels (e.g., `DisableAllPanels()`).

# Anti-Patterns
- Do not use `WaitForSeconds` or time-based delays for this specific single-frame issue; use a boolean flag.
- Do not perform click detection if `currentTransform` is null.
- Do not allow the activation click to propagate to the click-outside logic.

## Triggers

- Unity panel closes immediately when clicked
- prevent panel from closing on activation frame
- check click outside panel ignore first input
- UI panel manager click outside logic

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…