/// <summary> /// SetLayeredWindowsAttributes によって指定色を透過させる /// </summary> private void DisableTransparentBySetLayered() { #if UNITY_EDITOR // エディタの場合、設定すると描画が更新されなくなってしまう #else WinApi.COLORREF cref = new WinApi.COLORREF(0, 0, 0); WinApi.SetLayeredWindowAttributes(hWnd, cref, 0xFF, 0x00); long exstyle = this.CurrentWindowExStyle; exstyle &= ~WinApi.WS_EX_LAYERED; this.CurrentWindowExStyle = exstyle; WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.CurrentWindowExStyle); #endif }
/// <summary> /// SetLayeredWindowsAttributes によって指定色を透過させる /// </summary> private void EnableTransparentBySetLayered() { #if UNITY_EDITOR // エディタの場合、設定すると描画が更新されなくなってしまう #else Color32 color32 = ChromakeyColor; WinApi.COLORREF cref = new WinApi.COLORREF(color32.r, color32.g, color32.b); WinApi.SetLayeredWindowAttributes(hWnd, cref, 0xFF, WinApi.LWA_COLORKEY); long exstyle = this.CurrentWindowExStyle; exstyle |= WinApi.WS_EX_LAYERED; this.CurrentWindowExStyle = exstyle; WinApi.SetWindowLong(hWnd, WinApi.GWL_EXSTYLE, this.CurrentWindowExStyle); #endif }