Unity3d Export exe window parameter adjustment training

Source: Internet
Author: User

Welcome to Unity Learning, unity training, Unity Enterprise training and education zone, there are many u3d resources, u3d training videos, u3d tutorials, U3d Frequently asked questions, U3d Project source code, we are committed to creating the industry Unity3d training, learning the first brand.

Below we start today's unity3d skills training. We learn Unity3d training goals: let U3d beginners can more quickly grasp the u3d technology, make changes to their own materials, can be completed independently 2D, 3D small-scale games and web game development.

[CSharp] View plaincopy

  1. Using System;

  2. Using System.Runtime.InteropServices;

  3. Using Unityengine;

  4. public class Windowmod:monobehaviour

  5. {

  6. public enum Appstyle

  7. {

  8. Fullscreen,

  9. Windowedfullscreen,

  10. Windowed,

  11. Windowedwithoutborder

  12. }

  13. public enum Zdepth

  14. {

  15. Normal,

  16. Top,

  17. Topmost

  18. }

  19. Private Const UINT SWP_SHOWWINDOW = 64u;

  20. Private Const INT Gwl_style =-16;

  21. Private Const int ws_border = 1;

  22. Private Const INT Gwl_exstyle =-20;

  23. Private Const int ws_caption = 12582912;

  24. Private Const int ws_popup = 8388608;

  25. Private Const int sm_cxscreen = 0;

  26. Private Const int sm_cyscreen = 1;

  27. Public Windowmod.appstyle Appwindowstyle = WindowMod.appStyle.WindowedFullScreen;

  28. Public windowmod.zdepth screendepth;

  29. public int windowLeft = 10;

  30. public int windowtop = 10;

  31. public int windowwidth = 800;

  32. public int windowheight = 600;

  33. Private Rect screenposition;

  34. Private IntPtr hwnd_top = new IntPtr (0);

  35. Private IntPtr hwnd_topmost = new IntPtr (-1);

  36. Private IntPtr Hwnd_normal = new IntPtr (-2);

  37. private int xscreen;

  38. private int yscreen;

  39. private int i;

  40. [DllImport ("User32.dll")]

  41. private static extern IntPtr GetForegroundWindow ();

  42. [DllImport ("user32.dll", CharSet = CharSet.Auto)]

  43. public static extern bool SetWindowPos (IntPtr hWnd, IntPtr hpos, int x, int y, int cx, int cy, uint nflags);

  44. [DllImport ("User32.dll")]

  45. private static extern IntPtr FindWindow (string lpclassname, string lpwindowname);

  46. [DllImport ("User32.dll")]

  47. private static extern int SetWindowLong (IntPtr hWnd, int nIndex, int dwnewlong);

  48. [DllImport ("User32.dll")]

  49. private static extern int GetWindowLong (IntPtr hWnd, int dwnewlong);

  50. [DllImport ("User32.dll")]

  51. private static extern bool MoveWindow (IntPtr hWnd, int x, int y, int width, int height, bool repaint);

  52. [DllImport ("user32.dll", CharSet = CharSet.Auto)]

  53. public static extern int ShowWindow (INTPTR hwnd, int ncmdshow);

  54. [DllImport ("user32.dll", CharSet = CharSet.Auto)]

  55. public static extern int SendMessage (INTPTR hwnd, int msg, IntPtr WP, IntPtr IP);

  56. [DllImport ("user32.dll", CharSet = CharSet.Auto)]

  57. public static extern IntPtr SetParent (IntPtr hchild, IntPtr hparent);

  58. [DllImport ("user32.dll", CharSet = CharSet.Auto)]

  59. public static extern IntPtr GetParent (IntPtr hchild);

  60. [DllImport ("User32.dll")]

  61. public static extern IntPtr getsystemmetrics (int nIndex);

  62. private void Start ()

  63. {

  64. This. Xscreen = (int) windowmod.getsystemmetrics (0);

  65. This. Yscreen = (int) windowmod.getsystemmetrics (1);

  66. if (this. Appwindowstyle = = WindowMod.appStyle.FullScreen)

  67. {

  68. Screen.setresolution (this. Xscreen, this. Yscreen, True);

  69. }

  70. if (this. Appwindowstyle = = WindowMod.appStyle.WindowedFullScreen)

  71. {

  72. Screen.setresolution (this. Xscreen-1, this. Yscreen-1, false);

  73. This.screenposition = new Rect (0f, 0f, (float) (this. Xscreen-1), (float) (this. Yscreen-1));

  74. }

  75. if (this. Appwindowstyle = = WindowMod.appStyle.Windowed)

  76. {

  77. Screen.setresolution (This.windowwidth, This.windowwidth, false);

  78. }

  79. if (this. Appwindowstyle = = WindowMod.appStyle.WindowedWithoutBorder)

  80. {

  81. Screen.setresolution (This.windowwidth, This.windowwidth, false);

  82. This.screenposition = new Rect ((float) this.windowleft, (float) this.windowtop, (float) this.windowwidth, (float) This.windowwidth);

  83. }

  84. }

  85. private void Update ()

  86. {

  87. if (This.i < 5)

  88. {

  89. if (this. Appwindowstyle = = WindowMod.appStyle.WindowedFullScreen)

  90. {

  91. Windowmod.setwindowlong (Windowmod.getforegroundwindow (),-16, 369164288);

  92. if (this. Screendepth = = WindowMod.zDepth.Normal)

  93. {

  94. Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_normal, (int) this.screenposition.x, (int) this.screenposition.y, (int) this.screenPosition.width, (int) This.screenPosition.height, 64u);

  95. }

  96. if (this. Screendepth = = WindowMod.zDepth.Top)

  97. {

  98. Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_top, (int) this.screenposition.x, (int) this.screenposition.y, (int) this.screenPosition.width, (int) This.screenPosition.height, 64u);

  99. }

  100. if (this. Screendepth = = WindowMod.zDepth.TopMost)

  101. {

  102. Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_topmost, (int) this.screenposition.x, (int) this.screenposition.y, (int) this.screenPosition.width, (int) This.screenPosition.height, 64u);

  103. }

  104. Windowmod.showwindow (Windowmod.getforegroundwindow (), 3);

  105. }

  106. if (this. Appwindowstyle = = WindowMod.appStyle.Windowed)

  107. {

  108. if (this. Screendepth = = WindowMod.zDepth.Normal)

  109. {

  110. Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_normal, 0, 0, 0, 0, 3u);

  111. Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_normal, 0, 0, 0, 0, 35u);

  112. }

  113. if (this. Screendepth = = WindowMod.zDepth.Top)

  114. {

  115. Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_top, 0, 0, 0, 0, 3u);

  116. Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_top, 0, 0, 0, 0, 35u);

  117. }

  118. if (this. Screendepth = = WindowMod.zDepth.TopMost)

  119. {

  120. Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_topmost, 0, 0, 0, 0, 3u);

  121. Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_topmost, 0, 0, 0, 0, 35u);

  122. }

  123. }

  124. if (this. Appwindowstyle = = WindowMod.appStyle.WindowedWithoutBorder)

  125. {

  126. Windowmod.setwindowlong (Windowmod.getforegroundwindow (),-16, 369164288);

  127. if (this. Screendepth = = WindowMod.zDepth.Normal)

  128. {

  129. Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_normal, (int) this.screenposition.x, (int) this.screenposition.y, (int) this.screenPosition.width, (int) This.screenPosition.height, 64u);

  130. }

  131. if (this. Screendepth = = WindowMod.zDepth.Top)

  132. {

  133. &

For more highlights, please click http://www.gopedu.com/

Unity3d Export exe window parameter adjustment training

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.