PC设置窗口
using System;
using System.Runtime.InteropServices;
using UnityEngine;
public class MyWindow : MonoBehaviour
{
//使用查找任务栏
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string strClassName, int nptWindowName);
//当前窗口
[DllImport("user32.dll")] static extern IntPtr GetForegroundWindow();
//获取窗口位置以及大小
[DllImport("user32.dll")] static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
[StructLayout(LayoutKind.Sequential)]
private struct RECT
{
public int Left; //最左坐标
public int Top; //最上坐标
public int Right; //最右坐标
public int Bottom; //最下坐标
}
//设置窗口位置,尺寸
[DllImport("user32.dll")] static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
//设置无windows自带边框
[DllImport("user32.dll")] static extern IntPtr SetWindowLong(IntPtr hwnd, int _nIndex, int dwNewLong);
const uint SWP_SHOWWINDOW = 0x0040;
const int GWL_STYLE = -16;
const int WS_BORDER = 1;
Resolution[] resolutions;//分辨率
private Rect screenPosition;//最终的屏幕的位置和长宽
void Awake()
{
// Cursor.visible = false; // 鼠标隐藏
//获取当前屏幕分辩率
resolutions = Screen.resolutions;
//除任务栏外最大化窗口
witnOutBorder();
//设置全屏无边框
//Setposition();
}
/// <summary>
/// 获取当前窗口尺寸
/// </summary>
/// <returns></returns>
public Rect GetWindowInfo()
{
RECT rect = new RECT();
Rect targetRect = new Rect();
GetWindowRect(GetForegroundWindow()
