该模块功能:
1. 打包无边框
2. 置顶
3. 不允许切屏
4.多显示器状态下,程序只在主显示上运行
5.全屏
Unity 打包设置:
如果更改打包设置,最好将Version版本增加一下,否则可能不会覆盖前配置文件

代码: 挂在场景中即可
using UnityEngine;
using System; // 确保这行存在
using System.Runtime.InteropServices;
public class WindowTopMost : MonoBehaviour
{
#if !UNITY_EDITOR && UNITY_STANDALONE_WIN
    [DllImport("user32.dll")]
    private static extern bool SetWindowPos(IntPtr hwnd, 
                                           IntPtr hwndInsertAfter, 
                                           int x, int y, 
                                           int cx, int cy, 
                                           uint flags);
    [DllImport("user32.dll")]
    private static extern IntPtr GetActiveWindow();
    private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
    private const uint SWP_NOSIZE = 0x0001;
    private const uint SWP_NOMOVE = 0x0002;
    private const uint SWP_SHOWWINDOW = 0x0040;
    void Start()
    {
        Screen.SetResolution(Display.main.systemWidth, 
                            Display.main.systemHeight, 
                            FullScreenMode.FullScreenWindow);
        Invoke("SetWindowTopMost", 0.5f);
    }
    void SetWindowTopMost()
    {
        IntPtr windowPtr = GetActiveWindow();
        SetWindowPos(windowPtr, 
                    HWND_TOPMOST, 
                    0, 0, 0, 0, 
                    SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
    }
#endif
}


















