[Unity] Unity3D在Windows的全屏和跨屏(双屏)方案

查看:3585 |回复:17 | 2017-6-9 17:08:42

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 醉酒風 于 2019-4-28 22:49 编辑
  1. using System;
  2. using System.Collections;
  3. using System.Runtime.InteropServices;
  4. using System.Diagnostics;
  5. using UnityEngine;
  6. using System.Xml.Serialization;

  7. public class WindowMod : MonoBehaviour
  8. {
  9.     [HideInInspector]
  10.     public Rect screenPosition;
  11.     [DllImport("user32.dll")]
  12.     static extern IntPtr SetWindowLong(IntPtr hwnd, int _nIndex, int dwNewLong);
  13.     [DllImport("user32.dll")]
  14.     static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
  15.     [DllImport("user32.dll")]
  16.     static extern IntPtr GetActiveWindow();
  17.     const uint SWP_SHOWWINDOW = 0x0040;
  18.     const int GWL_STYLE = -16;
  19.     const int WS_BORDER = 1;
  20.     private int i = 0;

  21.     void Start()
  22.     {
  23.         SetWindowLong(GetActiveWindow(), GWL_STYLE, WS_BORDER);
  24.         SetWindowPos(GetActiveWindow(), -1, (int)screenPosition.x, (int)screenPosition.y, (int)screenPosition.width, (int)screenPosition.height, SWP_SHOWWINDOW);
  25.     }

  26.     void Update()
  27.     {
  28.         i++;
  29.         if(i<5)
  30.         {
  31.             SetWindowLong(GetActiveWindow(), GWL_STYLE, WS_BORDER);
  32.             SetWindowPos(GetActiveWindow(), -1, (int)screenPosition.x, (int)screenPosition.y, (int)screenPosition.width, (int)screenPosition.height, SWP_SHOWWINDOW);
  33.         }
  34.     }
  35. }
点击此处复制文本
1.jpg

评分

参与人数 1元素币 +3 展开 理由
狼之独步 + 3 你格式乱了,编辑时,放到code里就好了

查看全部评分

2017-6-9 17:08:42  
 赞 赞 0

使用道具 登录

17个回答,把该问题分享到群,邀请大神一起回答。
2#
这 我已无法直视
回复 收起回复
2017-6-9 20:55:03   回复
 赞 赞 0

使用道具 登录

3#
资源甚好,发帖艰辛,且阅且珍惜!
回复 收起回复
2017-6-9 22:52:21   回复
 赞 赞 0

使用道具 登录

4#
立刻提起了精神
回复 收起回复
2017-6-13 00:16:17   回复
 赞 赞 0

使用道具 登录

5#
哦,好厉害,好大的画面啊
回复 收起回复
2017-6-29 08:54:31   回复
 赞 赞 0

使用道具 登录

6#
没有图片截图示意下
回复 收起回复
2017-12-15 10:44:45   回复
 赞 赞 0

使用道具 登录

7#
新手跑来学习一下新手跑来学习一下!!
回复 收起回复
2018-2-26 22:17:50   回复
 赞 赞 0

使用道具 登录

8#
1111
回复 收起回复
2018-2-27 10:24:58   回复
 赞 赞 0

使用道具 登录

9#
1 delay脚本的数值是延迟多久播放。2 DelayedDestroyController的数值是几秒之后删除物体。有些特效元素我们希望他播放完毕就删除掉减小资源量的时候可以添加此脚本。1 delay脚本的数值是延迟多久播放。2 DelayedDestroyController的数值是几秒之后删除物体。有些特效元素我们希望他播放完毕就删除掉减小资源量的时候可以添加此脚本。1 delay脚本的数值是延迟多久播放。2 DelayedDestroyController的数值是几秒之后删除物体。有些特效元素我们希望他播放完毕就删除掉减小资源量的时候可以添加此脚本。
回复 收起回复
2018-11-28 13:23:41   回复
 赞 赞 0

使用道具 登录

10#
好看
回复 收起回复
2018-12-13 08:32:36   回复
 赞 赞 0

使用道具 登录

11#
感谢分享
回复 收起回复
2018-12-13 08:37:56   回复
 赞 赞 0

使用道具 登录

12#
回复 收起回复
2018-12-13 09:12:00   回复
 赞 赞 0

使用道具 登录

13#
超级棒棒棒
回复 收起回复
2018-12-23 17:06:56   回复
 赞 赞 0

使用道具 登录

14#
路过看看 感谢分享
回复 收起回复
2018-12-23 22:27:49   回复
 赞 赞 0

使用道具 登录

15#
路过看看 感谢分享
回复 收起回复
2018-12-23 22:27:51   回复
 赞 赞 0

使用道具 登录

16#
感谢分享
回复 收起回复
2018-12-24 00:11:17   回复
 赞 赞 0

使用道具 登录

17#
666
回复 收起回复
2019-3-29 14:23:49   回复
 赞 赞 0

使用道具 登录

18#
好好好
回复 收起回复
2019-4-2 23:37:59   回复
 赞 赞 0

使用道具 登录

CG 游戏行业专业问题

Unity3D技术手机游戏引擎手游引擎
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表