中文字幕无码a片久久,亚洲日韩在线观看浪潮,人人超人人超碰超国产二区,国产人妻久久一区二区,国产人妻久久一区二区

福感科技有限公司 歡迎您!
聯(lián)系方式

    地址:北京市平谷區(qū)馬坊鎮(zhèn)金河北街17號院3號樓7層712

    電話:010-89968230

    網(wǎng)站:http://0743119.com

Unity3D跨屏幕、全屏顯示方法

2021-3-21 22:48:08??????點擊:

Unity3D跨屏幕、全屏顯示方法,運行環(huán)境:Win10 64bit, Unity3D 2017.3.1

using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Diagnostics;
using UnityEngine;
using System.Xml.Serialization;

public class WindowMod : MonoBehaviour
{
    [HideInInspector]
    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("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 Start()
    {
        SetWindowLong(GetActiveWindow(), GWL_STYLE, WS_BORDER);
        SetWindowPos(GetActiveWindow(), -1, (int)screenPosition.x, (int)screenPosition.y, (int)screenPosition.width, (int)screenPosition.height, SWP_SHOWWINDOW);
    }

    void Update()
    {
        i++;
        if(i<5)
        {
            SetWindowLong(GetActiveWindow(), GWL_STYLE, WS_BORDER);
            SetWindowPos(GetActiveWindow(), -1, (int)screenPosition.x, (int)screenPosition.y, (int)screenPosition.width, (int)screenPosition.height, SWP_SHOWWINDOW);
        }
    }
}


上面這個腳本,可以使Unity3D窗口全屏,沒有標(biāo)題欄,通過更改screenPosition的值,還可以使窗口直接在第二個屏幕上啟動(x=0, y=0, width=1920, height=1080),或者窗口跨越兩個屏(x=0, y=0, width=3840, height=1080)。 如果使用讀取配置文件的方法, 可以自定義屏幕分辨率。Windows系統(tǒng)會記錄軟件的窗口大小和位置,并記錄在注冊表的\HKEY_CURRENT_USER\Software\xxx\yyy 位置,xxx是Unity3D在build設(shè)置中的Company Name,yyy是在Build設(shè)置中的Product Name。所以如果有時候窗口大小有問題,可以先備份注冊表,再刪除xxx項。建議每個項目的Product Name不要用默認(rèn)值,否則打包出來的軟件都會對應(yīng)到注冊表里相同的項。

Copyright 2019 0743119.com

福感科技有限公司 版權(quán)所有 All Rights Reserved

京ICP備20002031號

010-89968230