AutoSkill 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.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/unity-ui-panel-click-outside-debouncing" ~/.claude/skills/ecnu-icalk-autoskill-unity-ui-panel-click-outside-debouncing && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/unity-ui-panel-click-outside-debouncing/SKILL.mdsource content
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
- Debouncing Mechanism: Use a boolean flag (e.g.,
) to track whether the next mouse click should be ignored.ignoreNextClick - Activation Trigger: When a panel is activated (e.g., inside an
method), set theInit
flag toignoreNextClick
.true - Input Handling: In the
method, check forUpdate()
.Input.GetMouseButtonDown(0) - Flag Logic: If
isignoreNextClick
, reset it totrue
andfalse
immediately. Do not process the click-outside logic on this frame.return - Click-Outside Detection: If
isignoreNextClick
andfalse
is not null, convert the mouse position to local coordinates usingcurrentTransform
.currentTransform.InverseTransformPoint(Input.mousePosition) - Closure Logic: If the local mouse position is NOT contained within
, call the method to disable all panels (e.g.,currentTransform.rect
).DisableAllPanels()
Anti-Patterns
- Do not use
or time-based delays for this specific single-frame issue; use a boolean flag.WaitForSeconds - Do not perform click detection if
is null.currentTransform - 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