直接上代码
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);
}
}
看到这篇博客而受到的启发连接
打包设置如下