[Windowing] Enabling Transparent and Click-Through Functionality in Unity 6
Solution
Unity 2021.x - Unity 6.3.x
Published Tue, Mar 24
In Unity 6, developers face significant hurdles when attempting to create a transparent or click-through window. The primary obstacle is the default DirectX 12 rendering path and the DXGI Flip Model, which prevents the window from properly compositing with the desktop and ignores the alpha channel required for transparency.
Achieving a transparent and click-through state requires specific configuration of the rendering Swapchain and native OS calls. Unity 6 defaults to modern flip models that optimize for full-screen performance but break legacy alpha blending.
- Open
Project Settingsand select thePlayercategory. - Under
Other Settings, locateGraphics APIsand ensureDirectX 11is at the top of the list. Unity 6 requires this because the Swapchain transparency behavior is strictly defined forDirectX 11when using legacy window styles. - Navigate to
Resolution and Presentation. - Deselect
Use DXGI Flip Model Swapchain for D3D11. This allows the Swapchain to use older composition methods necessary for transparency. - Set
Fullscreen ModetoWindowedand ensureResizable Windowis checked. - To enable click-through functionality, your script must interface with the
user32.dllto modify the window styles at runtime.
Additional Tips
- Ensure the
Camera.clearFlagsis set toSolid Colorwith an alpha of 0 to allow the Swapchain to pass through. - Set
Application.runInBackgroundto true so the Swapchain remains active when focus is lost. - If the window is still opaque, verify that no
ImageorPanelelements in theCanvasare blocking the view with a high alpha value.
TL;DR
Transparency is enabled by forcing DirectX 11 and disabling the Use DXGI Flip Model Swapchain for D3D11 option in Project Settings to allow the Swapchain to blend with the desktop.
Related Posts Haven't quite found a solution to your problem? We think these posts might help you.
Content inspired by a Unity discussion post.