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.
Using System;
Using System.Runtime.InteropServices;
Using Unityengine;
public class Windowmod:monobehaviour
{
public enum Appstyle
{
Fullscreen,
Windowedfullscreen,
Windowed,
Windowedwithoutborder
}
public enum Zdepth
{
Normal,
Top,
Topmost
}
Private Const UINT SWP_SHOWWINDOW = 64u;
Private Const INT Gwl_style =-16;
Private Const int ws_border = 1;
Private Const INT Gwl_exstyle =-20;
Private Const int ws_caption = 12582912;
Private Const int ws_popup = 8388608;
Private Const int sm_cxscreen = 0;
Private Const int sm_cyscreen = 1;
Public Windowmod.appstyle Appwindowstyle = WindowMod.appStyle.WindowedFullScreen;
Public windowmod.zdepth screendepth;
public int windowLeft = 10;
public int windowtop = 10;
public int windowwidth = 800;
public int windowheight = 600;
Private Rect screenposition;
Private IntPtr hwnd_top = new IntPtr (0);
Private IntPtr hwnd_topmost = new IntPtr (-1);
Private IntPtr Hwnd_normal = new IntPtr (-2);
private int xscreen;
private int yscreen;
private int i;
[DllImport ("User32.dll")]
private static extern IntPtr GetForegroundWindow ();
[DllImport ("user32.dll", CharSet = CharSet.Auto)]
public static extern bool SetWindowPos (IntPtr hWnd, IntPtr hpos, int x, int y, int cx, int cy, uint nflags);
[DllImport ("User32.dll")]
private static extern IntPtr FindWindow (string lpclassname, string lpwindowname);
[DllImport ("User32.dll")]
private static extern int SetWindowLong (IntPtr hWnd, int nIndex, int dwnewlong);
[DllImport ("User32.dll")]
private static extern int GetWindowLong (IntPtr hWnd, int dwnewlong);
[DllImport ("User32.dll")]
private static extern bool MoveWindow (IntPtr hWnd, int x, int y, int width, int height, bool repaint);
[DllImport ("user32.dll", CharSet = CharSet.Auto)]
public static extern int ShowWindow (INTPTR hwnd, int ncmdshow);
[DllImport ("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage (INTPTR hwnd, int msg, IntPtr WP, IntPtr IP);
[DllImport ("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SetParent (IntPtr hchild, IntPtr hparent);
[DllImport ("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetParent (IntPtr hchild);
[DllImport ("User32.dll")]
public static extern IntPtr getsystemmetrics (int nIndex);
private void Start ()
{
This. Xscreen = (int) windowmod.getsystemmetrics (0);
This. Yscreen = (int) windowmod.getsystemmetrics (1);
if (this. Appwindowstyle = = WindowMod.appStyle.FullScreen)
{
Screen.setresolution (this. Xscreen, this. Yscreen, True);
}
if (this. Appwindowstyle = = WindowMod.appStyle.WindowedFullScreen)
{
Screen.setresolution (this. Xscreen-1, this. Yscreen-1, false);
This.screenposition = new Rect (0f, 0f, (float) (this. Xscreen-1), (float) (this. Yscreen-1));
}
if (this. Appwindowstyle = = WindowMod.appStyle.Windowed)
{
Screen.setresolution (This.windowwidth, This.windowwidth, false);
}
if (this. Appwindowstyle = = WindowMod.appStyle.WindowedWithoutBorder)
{
Screen.setresolution (This.windowwidth, This.windowwidth, false);
This.screenposition = new Rect ((float) this.windowleft, (float) this.windowtop, (float) this.windowwidth, (float) This.windowwidth);
}
}
private void Update ()
{
if (This.i < 5)
{
if (this. Appwindowstyle = = WindowMod.appStyle.WindowedFullScreen)
{
Windowmod.setwindowlong (Windowmod.getforegroundwindow (),-16, 369164288);
if (this. Screendepth = = WindowMod.zDepth.Normal)
{
Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_normal, (int) this.screenposition.x, (int) this.screenposition.y, (int) this.screenPosition.width, (int) This.screenPosition.height, 64u);
}
if (this. Screendepth = = WindowMod.zDepth.Top)
{
Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_top, (int) this.screenposition.x, (int) this.screenposition.y, (int) this.screenPosition.width, (int) This.screenPosition.height, 64u);
}
if (this. Screendepth = = WindowMod.zDepth.TopMost)
{
Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_topmost, (int) this.screenposition.x, (int) this.screenposition.y, (int) this.screenPosition.width, (int) This.screenPosition.height, 64u);
}
Windowmod.showwindow (Windowmod.getforegroundwindow (), 3);
}
if (this. Appwindowstyle = = WindowMod.appStyle.Windowed)
{
if (this. Screendepth = = WindowMod.zDepth.Normal)
{
Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_normal, 0, 0, 0, 0, 3u);
Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_normal, 0, 0, 0, 0, 35u);
}
if (this. Screendepth = = WindowMod.zDepth.Top)
{
Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_top, 0, 0, 0, 0, 3u);
Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_top, 0, 0, 0, 0, 35u);
}
if (this. Screendepth = = WindowMod.zDepth.TopMost)
{
Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_topmost, 0, 0, 0, 0, 3u);
Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_topmost, 0, 0, 0, 0, 35u);
}
}
if (this. Appwindowstyle = = WindowMod.appStyle.WindowedWithoutBorder)
{
Windowmod.setwindowlong (Windowmod.getforegroundwindow (),-16, 369164288);
if (this. Screendepth = = WindowMod.zDepth.Normal)
{
Windowmod.setwindowpos (Windowmod.getforegroundwindow (), this. Hwnd_normal, (int) this.screenposition.x, (int) this.screenposition.y, (int) this.screenPosition.width, (int) This.screenPosition.height, 64u);
}
if (this. Screendepth = = WindowMod.zDepth.Top)
{
&