zoukankan      html  css  js  c++  java
  • Unity3D导出exe窗口参数调整培训

    欢迎来到unity学习unity培训、unity企业培训教育专区,这里有很多U3D资源U3D培训视频U3D教程U3D常见问题U3D项目源码,我们致力于打造业内unity3d培训、学习第一品牌。

    下面我们开始今天的Unity3D技能培训。 我们学习Unity3D培训目标:让U3D初学者可以更快速的掌握U3D技术,自行制作修改素材,可以独立完成2D、3D小规模游戏及网页游戏开发。

    [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. &

    更多精彩请点击 http://www.gopedu.com/

  • 相关阅读:
    【字符串处理算法】字符串包含的算法设计及C代码实现【转】
    linux中字符串转换函数 simple_strtoul【转】
    Linux内核空间内存申请函数kmalloc、kzalloc、vmalloc的区别【转】
    linux非阻塞的socket EAGAIN的错误处理【转】
    嵌入式 uboot引导kernel,kernel引导fs【转】
    jQuery入门(4)jQuery中的Ajax应用
    jQuery入门(3)事件与事件对象
    jQuery入门(2)使用jQuery操作元素的属性与样式
    jQuery入门(1)jQuery中万能的选择器
    JavaScript在IE6下超级链接window.location.href不跳转的bug 及 解决方案
  • 原文地址:https://www.cnblogs.com/Unity3Dqishituan/p/4022821.html
Copyright © 2011-2022 走看看