Unity如何在Win10的主屏和扩展屏上显示一个窗口应用程序
我的电脑上多接了一个显示屏,我希望Unity程序显示在主屏和扩展屏上,类似于1*2的拼接屏
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Diagnostics;
using UnityEngine;
using System.Xml.Serialization;
public class MainDisplay : MonoBehaviour
{
[DllImport("user32.dll")]
static extern IntPtr SetWindowLong(IntPtr hwnd, int _nIndex, int dwNewLong);
//导入设置窗口函数
[DllImport("user32.dll")]
public static extern bool SetWindowPos(System.IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
//导入当前活动窗口
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
public static extern IntPtr GetActiveWindow();
//显示窗口
public const uint SWP_SHOWWINDOW = 0x0040;
const int GWL_STYLE = -16;
const int WS_BORDER = 1;
void Start()
{
//最后一个参数必须为false,不能直接全屏
Screen.SetResolution(3240, 1920, false);
//隐藏标题栏
SetWindowLong(GetForegroundWindow(), GWL_STYLE, WS_BORDER);
SetWindowPos(GetActiveWindow(), -1, 0, 0, 3240, 1920, SWP_SHOWWINDOW);
}
}


浙公网安备 33010602011771号