Created
February 22, 2018 19:55
-
-
Save DenchiSoft/67066025dbfdbf89e4b07976fe6c3b8b to your computer and use it in GitHub Desktop.
Setting the window to consume or pass through clicks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [DllImport("user32.dll", EntryPoint = "SetLayeredWindowAttributes")] | |
| private static extern int SetLayeredWindowAttributes(IntPtr hwnd, int crKey, byte bAlpha, int dwFlags); | |
| [DllImport("user32.dll")] | |
| private static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong); | |
| // Sets window to pass through clicks. | |
| private void SetInactive() { | |
| #if !UNITY_EDITOR | |
| SetWindowLong(hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE); | |
| SetWindowLong (hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW | WS_EX_LAYERED | WS_EX_TRANSPARENT); | |
| SetLayeredWindowAttributes (hwnd, 0, 255, LWA_ALPHA); | |
| #endif | |
| } | |
| // Sets window to consume clicks. | |
| private void SetActive() { | |
| #if !UNITY_EDITOR | |
| SetWindowLong (hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW | ~((WS_EX_LAYERED) | (WS_EX_TRANSPARENT))); | |
| #endif | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment