Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.96 KB | None | 0 0
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using UnityEngine;
  4.  
  5. // Token: 0x02000007 RID: 7
  6. [RequireComponent(typeof(Camera))]
  7. public class TransparentWindow : MonoBehaviour
  8. {
  9.     // Token: 0x0600000F RID: 15
  10.     [DllImport("user32.dll")]
  11.     private static extern IntPtr GetActiveWindow();
  12.  
  13.     // Token: 0x06000010 RID: 16
  14.     [DllImport("user32.dll")]
  15.     private static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong);
  16.  
  17.     // Token: 0x06000011 RID: 17
  18.     [DllImport("user32.dll")]
  19.     private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
  20.  
  21.     // Token: 0x06000012 RID: 18
  22.     [DllImport("user32.dll")]
  23.     private static extern int SetLayeredWindowAttributes(IntPtr hwnd, int crKey, byte bAlpha, int dwFlags);
  24.  
  25.     // Token: 0x06000013 RID: 19
  26.     [DllImport("user32.dll")]
  27.     private static extern int SetWindowPos(IntPtr hwnd, int hwndInsertAfter, int x, int y, int cx, int cy, int uFlags);
  28.  
  29.     // Token: 0x06000014 RID: 20
  30.     [DllImport("Dwmapi.dll")]
  31.     private static extern uint DwmExtendFrameIntoClientArea(IntPtr hWnd, ref TransparentWindow.MARGINS margins);
  32.  
  33.     // Token: 0x06000015 RID: 21 RVA: 0x00002380 File Offset: 0x00000580
  34.     private void Start()
  35.     {
  36.         this.mainCamera = base.GetComponent<Camera>();
  37.         this.fWidth = Screen.width;
  38.         this.fHeight = Screen.height;
  39.         this.margins = new TransparentWindow.MARGINS
  40.         {
  41.             cxLeftWidth = -1
  42.         };
  43.         this.hwnd = TransparentWindow.GetActiveWindow();
  44.         TransparentWindow.SetWindowLong(this.hwnd, -16, 2415919104u);
  45.         TransparentWindow.SetWindowPos(this.hwnd, -1, 0, 0, this.fWidth, this.fHeight, 96);
  46.         TransparentWindow.DwmExtendFrameIntoClientArea(this.hwnd, ref this.margins);
  47.         Application.runInBackground = true;
  48.     }
  49.  
  50.     // Token: 0x06000016 RID: 22 RVA: 0x0000241C File Offset: 0x0000061C
  51.     private void Update()
  52.     {
  53.         RaycastHit raycastHit = default(RaycastHit);
  54.         this.clickThrough = !Physics.Raycast(this.mainCamera.ScreenPointToRay(Input.mousePosition).origin, this.mainCamera.ScreenPointToRay(Input.mousePosition).direction, out raycastHit, 100f, -5);
  55.         if (this.clickThrough != this.prevClickThrough)
  56.         {
  57.             if (this.clickThrough)
  58.             {
  59.                 TransparentWindow.SetWindowLong(this.hwnd, -16, 2415919104u);
  60.                 TransparentWindow.SetWindowLong(this.hwnd, -20, 524320u);
  61.                 TransparentWindow.SetLayeredWindowAttributes(this.hwnd, 0, byte.MaxValue, 2);
  62.                 TransparentWindow.SetWindowPos(this.hwnd, -1, 0, 0, this.fWidth, this.fHeight, 96);
  63.             }
  64.             else
  65.             {
  66.                 TransparentWindow.SetWindowLong(this.hwnd, -20, 4294442975u);
  67.                 TransparentWindow.SetWindowPos(this.hwnd, -1, 0, 0, this.fWidth, this.fHeight, 96);
  68.             }
  69.             this.prevClickThrough = this.clickThrough;
  70.         }
  71.     }
  72.  
  73.     // Token: 0x06000017 RID: 23 RVA: 0x00002525 File Offset: 0x00000725
  74.     private void OnRenderImage(RenderTexture from, RenderTexture to)
  75.     {
  76.         Graphics.Blit(from, to, this.m_Material);
  77.     }
  78.  
  79.     // Token: 0x04000012 RID: 18
  80.     [SerializeField]
  81.     private Material m_Material;
  82.  
  83.     // Token: 0x04000013 RID: 19
  84.     [SerializeField]
  85.     private Camera mainCamera;
  86.  
  87.     // Token: 0x04000014 RID: 20
  88.     private bool clickThrough = true;
  89.  
  90.     // Token: 0x04000015 RID: 21
  91.     private bool prevClickThrough = true;
  92.  
  93.     // Token: 0x04000016 RID: 22
  94.     private const int GWL_STYLE = -16;
  95.  
  96.     // Token: 0x04000017 RID: 23
  97.     private const uint WS_POPUP = 2147483648u;
  98.  
  99.     // Token: 0x04000018 RID: 24
  100.     private const uint WS_VISIBLE = 268435456u;
  101.  
  102.     // Token: 0x04000019 RID: 25
  103.     private const int HWND_TOPMOST = -1;
  104.  
  105.     // Token: 0x0400001A RID: 26
  106.     private int fWidth;
  107.  
  108.     // Token: 0x0400001B RID: 27
  109.     private int fHeight;
  110.  
  111.     // Token: 0x0400001C RID: 28
  112.     private IntPtr hwnd;
  113.  
  114.     // Token: 0x0400001D RID: 29
  115.     private TransparentWindow.MARGINS margins;
  116.  
  117.     // Token: 0x0200003E RID: 62
  118.     private struct MARGINS
  119.     {
  120.         // Token: 0x04000247 RID: 583
  121.         public int cxLeftWidth;
  122.  
  123.         // Token: 0x04000248 RID: 584
  124.         public int cxRightWidth;
  125.  
  126.         // Token: 0x04000249 RID: 585
  127.         public int cyTopHeight;
  128.  
  129.         // Token: 0x0400024A RID: 586
  130.         public int cyBottomHeight;
  131.     }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement