using UnityEngine;
using System.Collections;
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using Debug = UnityEngine.Debug;
public class MainScriptfull : MonoBehaviour
{
public Rect screenPosition;
[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(“kernel32”, CharSet = CharSet.Auto)]
public static extern int GetPrivateProfileInt(string section, string key, int def, string filePath);
[DllImport(“user32.dll”)]
static extern IntPtr GetActiveWindow();
const uint SWP_SHOWWINDOW = 0x0040;
const int GWL_STYLE = -16;
const int WS_BORDER = 1;
private int i = 0;
void Awake()
{
if (ReadScreenWidth() == 0 || ReadScreenHeight() == 0)
{
int
Unity控制窗口全屏显示
最新推荐文章于 2025-10-20 14:00:46 发布
这篇博客介绍了一个Unity脚本,用于控制游戏窗口全屏显示。通过使用DllImport导入Windows API函数,设置窗口风格和位置,实现了在Awake和Start阶段将Unity窗口调整为全屏。同时,脚本还包含了读取和写入配置文件的功能,以便保存和恢复窗口尺寸。

最低0.47元/天 解锁文章

1532

被折叠的 条评论
为什么被折叠?



