- using UnityEngine;
- using System.Collections;
- using System.Runtime.InteropServices;
- using System;
- public class Test : MonoBehaviour
- {
- /// <summary>
- /// 窗口宽度
- /// </summary>
- public int winWidth;
- /// <summary>
- /// 窗口高度
- /// </summary>
- public int winHeight;
- /// <summary>
- /// 窗口左上角x
- /// </summary>
- public int winPosX;
- /// <summary>
- /// 窗口左上角y
- /// </summary>
- public int winPosY;
- [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();
- const uint SWP_SHOWWINDOW = 0x0040;
- const int GWL_STYLE = -16;
- const int WS_BORDER = 1;
- const int WS_POPUP = 0x800000;
- // Use this for initialization
- void Start()
- {
- winWidth = 610;
- winHeight = 350;
- //显示器支持的所有分辨率
- int i = Screen.resolutions.Length;
- int resWidth = Screen.resolutions[i - 1].width;
- int resHeight = Screen.resolutions[i - 1].height;
- winPosX = resWidth / 2 - winWidth / 2;
- winPosY = resHeight / 2 - winHeight / 2;
- SetWindowLong(GetForegroundWindow(), GWL_STYLE, WS_POPUP);
- bool result = SetWindowPos(GetForegroundWindow(), 0, winPosX, winPosY, winWidth, winHeight, SWP_SHOWWINDOW);
- }
- }
测试发现GUI坐标偏差,修改如下
- using UnityEngine;
- using System.Collections;
- using System.Runtime.InteropServices;
- using System;
- public class Test : MonoBehaviour
- {
- /// <summary>
- /// 窗口宽度
- /// </summary>
- public int winWidth;
- /// <summary>
- /// 窗口高度
- /// </summary>
- public int winHeight;
- /// <summary>
- /// 窗口左上角x
- /// </summary>
- public int winPosX;
- /// <summary>
- /// 窗口左上角y
- /// </summary>
- public int winPosY;
- [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();
- [DllImport("User32.dll", EntryPoint = "GetSystemMetrics")]
- public static extern IntPtr GetSystemMetrics(int nIndex);
- const int SM_CXSCREEN = 0x00000000;
- const int SM_CYSCREEN = 0x00000001;
- const uint SWP_SHOWWINDOW = 0x0040;
- const int GWL_STYLE = -16;
- const int WS_BORDER = 1;
- const int WS_POPUP = 0x800000;
- public GUIText t;
- // Use this for initialization
- void Start()
- {
- winWidth = 610;
- winHeight = 350;
- //当前屏幕分辨率
- int resWidth = (int)GetSystemMetrics(SM_CXSCREEN);
- int resHeight = (int)GetSystemMetrics(SM_CYSCREEN);
- winPosX = resWidth / 2 - winWidth / 2;
- winPosY = resHeight / 2 - winHeight / 2 -1;
- SetWindowLong(GetForegroundWindow(), GWL_STYLE, WS_POPUP);
- //测试发现左下角坐标为(0,1),修改如下
- bool result = SetWindowPos(GetForegroundWindow(), 0, winPosX, winPosY, winWidth, winHeight, SWP_SHOWWINDOW);
- //bool result = SetWindowPos(GetForegroundWindow(), 0, winPosX, winPosY, winWidth, winHeight, SWP_SHOWWINDOW);
- }
- void OnGUI()
- {
- if (Input.GetMouseButtonDown(0))
- {
- t.text = "X:"+Input.mousePosition.x + " Y:" + Input.mousePosition.y;
- }
- }
- }
相关推荐
Unity导exe 去掉程序边框
unity3d outline shader 边框 着色器
Unity打包exe去边框,置顶,透明,透明穿透解决方案,19后版本Edit——ProjectSettings——Player——ResolutionandPresentation——UseDXGIFlipModelSwapchainforD3D11选项设为false. 脚本随便挂,摄像机的Clear Flags...
Unity3D中物体的轮廓显示,此处分为薄边和厚边两种。无入侵式实现。
主要为大家详细介绍了Unity3D实现描边框效果,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
这是已经设置好的Unity文件,只需要把脚本 (TransparentWindow) 放入摄像机 (Main Camera) 中加入材质球点击导出 (Build) 运行一下就行了
Unity3D 模型的几种线框 shader。 模型的几种线框shader。 模型的几种线框shader,需要线框化模型的时候使用,比如选中模型线框化,只能看到模型线,看不到三角面 Unity3d Shader
Unity3D 界面插件 NGUI基础学习,带图详解 1.创建你的界面 2.精灵Sprite 3.SlideSprite 4.拼贴精灵TiledSprite 5.标签 6.按钮 7.滑块 8.复选框 9.输入框 10.2D转3D
可以让build出来的程序无边框运行并置顶,并且默认隐藏鼠标,可以自适应屏幕,也可以在双屏模式下延伸屏幕,可以置顶也可以置底,拖入改参数即可,变量名已经改成中文方便理解
炫酷的Unity3d UI 自定义圆角面板 插件 Unity UI 圆角面板 - 这是一个简单而实用的Unity资产,可在Unity中创建圆角面板。使用此资源,您可以轻松创建许多形式的Unity ui按钮图片等面板,赶快试试吧! 优点: - ...
unity3d 粒子特效包,主要有的效果是雨,雪,烟雾等特效制作
圆角图片边框Shader(Unity Package) 这个Unity Shader包提供了一种简单而有效的方法来为图片添加圆角和边框效果。通过使用这个Shader,你可以轻松地为任何2D图像创建平滑的圆角效果,并在需要时添加自定义颜色和...
去除下拉框的边框,包括下拉的按钮,内有demo
自己总结出来的unity3d发布窗口设置,可以指定位置,大小,窗口式样(边框,标题,按钮,滚动条,隐藏,激活,置顶,置底等)。 下载之后直接把脚本挂物体上就可使用。 如果有不明白的请打开脚本,脚本里面的注释...
按钮边框流光特效
本资源实现了以下需求: 点选物体:点击物体,可以选中物体,按住 Ctrl... 框选物体:拖拽鼠标,屏幕上会出现滑动框,滑动框内的物体会被选中,选中的物体设置为红色。 绘制外边框:给选中的物体绘制外边框(选中框)。
dialog去除边框代码
去除边框和分隔线
基于Qt5的去掉标题栏之后添加边框阴影的解决方案。 四种解决方法: 1. 如果是Windows平台,那么可以调用Windows相关API。 2. 使用Qt的QGraphicsDropShadowEffect类来实现。 3. 使用Qt的qDrawBorderPixmap函数来实现...