Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Runtime.InteropServices;
- using UnityEngine;
- // Token: 0x02000007 RID: 7
- [RequireComponent(typeof(Camera))]
- public class TransparentWindow : MonoBehaviour
- {
- // Token: 0x0600000F RID: 15
- [DllImport("user32.dll")]
- private static extern IntPtr GetActiveWindow();
- // Token: 0x06000010 RID: 16
- [DllImport("user32.dll")]
- private static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong);
- // Token: 0x06000011 RID: 17
- [DllImport("user32.dll")]
- private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
- // Token: 0x06000012 RID: 18
- [DllImport("user32.dll")]
- private static extern int SetLayeredWindowAttributes(IntPtr hwnd, int crKey, byte bAlpha, int dwFlags);
- // Token: 0x06000013 RID: 19
- [DllImport("user32.dll")]
- private static extern int SetWindowPos(IntPtr hwnd, int hwndInsertAfter, int x, int y, int cx, int cy, int uFlags);
- // Token: 0x06000014 RID: 20
- [DllImport("Dwmapi.dll")]
- private static extern uint DwmExtendFrameIntoClientArea(IntPtr hWnd, ref TransparentWindow.MARGINS margins);
- // Token: 0x06000015 RID: 21 RVA: 0x00002380 File Offset: 0x00000580
- private void Start()
- {
- this.mainCamera = base.GetComponent<Camera>();
- this.fWidth = Screen.width;
- this.fHeight = Screen.height;
- this.margins = new TransparentWindow.MARGINS
- {
- cxLeftWidth = -1
- };
- this.hwnd = TransparentWindow.GetActiveWindow();
- TransparentWindow.SetWindowLong(this.hwnd, -16, 2415919104u);
- TransparentWindow.SetWindowPos(this.hwnd, -1, 0, 0, this.fWidth, this.fHeight, 96);
- TransparentWindow.DwmExtendFrameIntoClientArea(this.hwnd, ref this.margins);
- Application.runInBackground = true;
- }
- // Token: 0x06000016 RID: 22 RVA: 0x0000241C File Offset: 0x0000061C
- private void Update()
- {
- RaycastHit raycastHit = default(RaycastHit);
- this.clickThrough = !Physics.Raycast(this.mainCamera.ScreenPointToRay(Input.mousePosition).origin, this.mainCamera.ScreenPointToRay(Input.mousePosition).direction, out raycastHit, 100f, -5);
- if (this.clickThrough != this.prevClickThrough)
- {
- if (this.clickThrough)
- {
- TransparentWindow.SetWindowLong(this.hwnd, -16, 2415919104u);
- TransparentWindow.SetWindowLong(this.hwnd, -20, 524320u);
- TransparentWindow.SetLayeredWindowAttributes(this.hwnd, 0, byte.MaxValue, 2);
- TransparentWindow.SetWindowPos(this.hwnd, -1, 0, 0, this.fWidth, this.fHeight, 96);
- }
- else
- {
- TransparentWindow.SetWindowLong(this.hwnd, -20, 4294442975u);
- TransparentWindow.SetWindowPos(this.hwnd, -1, 0, 0, this.fWidth, this.fHeight, 96);
- }
- this.prevClickThrough = this.clickThrough;
- }
- }
- // Token: 0x06000017 RID: 23 RVA: 0x00002525 File Offset: 0x00000725
- private void OnRenderImage(RenderTexture from, RenderTexture to)
- {
- Graphics.Blit(from, to, this.m_Material);
- }
- // Token: 0x04000012 RID: 18
- [SerializeField]
- private Material m_Material;
- // Token: 0x04000013 RID: 19
- [SerializeField]
- private Camera mainCamera;
- // Token: 0x04000014 RID: 20
- private bool clickThrough = true;
- // Token: 0x04000015 RID: 21
- private bool prevClickThrough = true;
- // Token: 0x04000016 RID: 22
- private const int GWL_STYLE = -16;
- // Token: 0x04000017 RID: 23
- private const uint WS_POPUP = 2147483648u;
- // Token: 0x04000018 RID: 24
- private const uint WS_VISIBLE = 268435456u;
- // Token: 0x04000019 RID: 25
- private const int HWND_TOPMOST = -1;
- // Token: 0x0400001A RID: 26
- private int fWidth;
- // Token: 0x0400001B RID: 27
- private int fHeight;
- // Token: 0x0400001C RID: 28
- private IntPtr hwnd;
- // Token: 0x0400001D RID: 29
- private TransparentWindow.MARGINS margins;
- // Token: 0x0200003E RID: 62
- private struct MARGINS
- {
- // Token: 0x04000247 RID: 583
- public int cxLeftWidth;
- // Token: 0x04000248 RID: 584
- public int cxRightWidth;
- // Token: 0x04000249 RID: 585
- public int cyTopHeight;
- // Token: 0x0400024A RID: 586
- public int cyBottomHeight;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement