Unity窗口化无边框模式
2015-12-28 13:33
543 查看
将下面代码复制进入脚本里,然后随便放到一个物体上即可实现窗口化启动无边框哦~
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Diagnostics;
using UnityEngine;
public class WindowMod : MonoBehaviour
{
public Rect screenPosition;
[DllImport(“user32.dll”)]
static extern IntPtr SetWindowLong(IntPtr hwnd, int _nIndex, int dwNewLong);
[DllImport(“user32.dll”)]
static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
[DllImport(“user32.dll”)]
static extern IntPtr GetForegroundWindow();
// not used rigth now
//const uint SWP_NOMOVE = 0x2;
//const uint SWP_NOSIZE = 1;
//const uint SWP_NOZORDER = 0x4;
//const uint SWP_HIDEWINDOW = 0x0080;
const uint SWP_SHOWWINDOW = 0x0040;
const int GWL_STYLE = -16;
const int WS_BORDER = 1;
void Start()
{
SetWindowLong(GetForegroundWindow(), GWL_STYLE, WS_BORDER);
bool result = SetWindowPos(GetForegroundWindow(), 0, (int)screenPosition.x, (int)screenPosition.y, (int)screenPosition.width, (int)screenPosition.height, SWP_SHOWWINDOW);
}
}
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Diagnostics;
using UnityEngine;
public class WindowMod : MonoBehaviour
{
public Rect screenPosition;
[DllImport(“user32.dll”)]
static extern IntPtr SetWindowLong(IntPtr hwnd, int _nIndex, int dwNewLong);
[DllImport(“user32.dll”)]
static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
[DllImport(“user32.dll”)]
static extern IntPtr GetForegroundWindow();
// not used rigth now
//const uint SWP_NOMOVE = 0x2;
//const uint SWP_NOSIZE = 1;
//const uint SWP_NOZORDER = 0x4;
//const uint SWP_HIDEWINDOW = 0x0080;
const uint SWP_SHOWWINDOW = 0x0040;
const int GWL_STYLE = -16;
const int WS_BORDER = 1;
void Start()
{
SetWindowLong(GetForegroundWindow(), GWL_STYLE, WS_BORDER);
bool result = SetWindowPos(GetForegroundWindow(), 0, (int)screenPosition.x, (int)screenPosition.y, (int)screenPosition.width, (int)screenPosition.height, SWP_SHOWWINDOW);
}
}
相关文章推荐
- Unity获取游戏对象
- Unity调用外部EXE和启动浏览器(手机端也可以启动IE内核)
- unity中宏定义平台
- Unity3D AssetStore下载的文件保存位置
- Unity3D 摄像机
- Unity3D 2D游戏开发 官方教程。(二)
- blender 给人物角色绑定骨骼到unity3d
- unity, StopAllCoroutines导致bug的解决办法
- Unity3D 2D游戏开发 官方教程。(三)
- Unity3D 2D游戏开发 官方教程。(一)
- 【Unity实用小方法】判断贴图是否为透明贴图
- unity 定位
- 从Unity引擎过度到Unreal4引擎(最终版)
- Unity官网教程之Tips
- Unity3D必备知识: 物理学公式
- 解读Unity中的CG编写Shader系列1——初识CG
- 【Unity Shader】基于UGUI的水波倒影按钮
- C# 文件选择对话框,Unity3d文件保存对话框
- Unity3D教程:茄子童萌會
- Unity3D 发布无边框exe