UnityRef is currently in early development. Some features may be incomplete and/or not functioning.

UNITYREF

Your Pit Stop For Solving ANYTHING in Unity

graphics

[Windowing] Enabling Transparent and Click-Through Functionality in Unity 6

Solution

renderingvisuals

Unity 2021.x - Unity 6.3.x

Published Tue, Mar 24

Issue

 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.

Explanation

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.

  1. Open Project Settings and select the Player category.
  2. Under Other Settings, locate Graphics APIs and ensure DirectX 11 is at the top of the list. Unity 6 requires this because the Swapchain transparency behavior is strictly defined for DirectX 11 when using legacy window styles.
  3. Navigate to Resolution and Presentation.
  4. Deselect Use DXGI Flip Model Swapchain for D3D11. This allows the Swapchain to use older composition methods necessary for transparency.
  5. Set Fullscreen Mode to Windowed and ensure Resizable Window is checked.
  6. To enable click-through functionality, your script must interface with the user32.dll to modify the window styles at runtime.

Additional Tips

  • Ensure the Camera.clearFlags is set to Solid Color with an alpha of 0 to allow the Swapchain to pass through.
  • Set Application.runInBackground to true so the Swapchain remains active when focus is lost.
  • If the window is still opaque, verify that no Image or Panel elements in the Canvas are 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.