UGTK / Toolkit / Ui Module / Click Effect Button Completed
Click Effect Button
Summary
The Click Effect Button adds a physical press feedback to UI buttons: on pointer down it hides Shadow/Outline effects and shifts the RectTransform by a fixed offset. Values restore on release, click, disable, or OnEnable.
Content
Modules Dependencies
None inside UGTK beyond Unity UI. The module ships the ClickEffectButton prefab with the
component already wired to its own Button and Image.
Setup
To set up the Click Effect Button, follow these steps:
- Add
Mn_ClickEffectButtonto a UI GameObject (or use GameObject → UGTK → UI → Click Effect Button). - Unity auto-adds
ButtonandShadow(RequireComponent). - Default offset is fixed at (20, -20) for both press movement and
Shadow.effectDistance. - Optionally disable Disable Child Graphic Raycasts if child graphics must receive pointer events.
Good to know:
- The offset moves the RectTransform and the
Shadow.effectDistancetogether: that is what sells the "the button sinks into its own shadow" feel. Changing only one of the two breaks the illusion. - The offset is fixed by design, not configurable per instance.
ApplySettingsandOnValidatereassign it to(20, -20)and the custom inspector shows it in a disabled Fixed Offset (read-only) field: the point is that every button in the project sinks by exactly the same amount. To change it project-wide editDefaultOffsetX/DefaultOffsetYinS_ClickEffectButtonSettings— do not expect the inspector value to stick. ButtonandShadoware auto-added (RequireComponent): do not remove them, and do not add a secondShadow— the component drives the first one it finds.- The state is restored on release, on click, on
OnDisableand again onOnEnable, so a button disabled mid-press (a panel that closes under the finger) never comes back stuck in the pressed position. - Disable Child Graphic Raycasts is on by default: child graphics do not capture the pointer, so the press is always detected on the button itself. Turn it off only if a child really needs its own pointer events.
Testing Scene
Open Debug/ClickEffectButtonScene.unity and press Play: hold the button down and it sinks by the
configured offset, release and it comes back.
Technical Info
The following are the main scripts and their functionalities:
Scripts:
- S_ClickEffectButtonSettings: Serializable settings struct (effect offset and child raycast behaviour).
- Mn_ClickEffectButton: Press/release visual handler implementing
IPointerDownHandlerandIPointerUpHandler. - Mn_ClickEffectButton_Editor: Inspector help box and Apply Settings To Components button.
Mn_ClickEffectButton API: ApplySettings(), DefaultEffectOffset
| Path | Content |
|---|---|
Scripts/Runtime/Mn_ClickEffectButton.cs |
Runtime press effect |
Scripts/Runtime/S_ClickEffectButtonSettings.cs |
Settings struct |
Scripts/Editor/Mn_ClickEffectButton_Editor.cs |
Custom inspector |
Prefabs/ClickEffectButton.prefab |
Ready-to-use button prefab |
Debug/ClickEffectButtonScene.unity |
Test scene |
© 2026 Marcello De Bonis. All rights reserved
UGTKengine within an engine


