Untiy的PC端强制全屏、去掉标题栏插件简单使用

Untiy的PC端强制全屏插件简单使用

前言

在之前的公司做的项目中,客户经常要求将程序设置成全屏。Unity自己打包设置中虽然也有全屏的设置,但是效果不是很好,而且不能强制置顶,经常被其它应用程序遮盖。所以我在这里安利一个Unity强制全屏的插件,可以非常简单地解决这个问题…

使用步骤

1.将插件解压到项目中,如图所示:
在这里插入图片描述
2.将Prafabs文件夹中的WindowMod预制体拖入场景中,如图所示:
在这里插入图片描述
3.WindowMod.cs脚本代码如下所示:

using System;
using System.Runtime.InteropServices;
using UnityEngine;
public class WindowMod : MonoBehaviour
{
   
    public enum appStyle
    {
   
        FullScreen,
        WindowedFullScreen,
        Windowed,
        WindowedWithoutBorder
    }
    public enum zDepth
    {
   
        Normal,
        Top,
        TopMost
    }
    private const uint SWP_SHOWWINDOW = 64u;
    private const int GWL_STYLE = -16;
    private const int WS_BORDER = 1;
    private const int GWL_EXSTYLE = -20;
    private const int WS_CAPTION = 12582912;
    private const int WS_POPUP = 8388608;
    private const int SM_CXSCREEN = 0;
    private const int SM_CYSCREEN = 1;
    public WindowMod.appStyle AppWindowStyle = WindowMod.appStyle.WindowedFullScreen;
    public WindowMod.zDepth ScreenDepth;
    private int windowLeft = 0;
    private int windowTop = 0;
    private int windowWidth = 1008;
    private int windowHeight = 567;
    private Rect screenPosition;
    private IntPtr HWND_TOP = new IntPtr(0);
    private IntPtr HWND_TOPMOST = new IntPtr(-1);
    private IntPtr HWND_NORMAL = new IntPtr(-2);
    private int Xscreen;
    private int Yscreen;
    private int i;
    [DllImport("user32.dll")]
    private static extern IntPtr GetForegroundWindow();
    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hPos, int x, int y, int cx, int cy, uint nflags);
    [DllImport("User32.dll")]
    private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    [DllImport(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

波波斯维奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值