zoukankan      html  css  js  c++  java
  • Unity3D在Windows的全屏和跨屏(双屏)方案

    方案1 unity中2个摄像机场景显示在两个显示器屏幕上(一个窗口跨屏)

    1.设置场景中的两个摄像机

    摄像机1

    摄像机2

    2.设置发布的平台及分辨率

    3.全屏运行游戏,没有标题栏还可以通过-popupwindow

    例如:

    G:untiy3d_workspaceDemos>lol_demo_0515 -popupwindow

    方案2

    http://blog.csdn.net/a117653909/article/details/47101743

    环境:Win7 64bit, Unity3D 4.6.2

    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);
            }
        }
    }

    Build设置 
    上图,Build设置 
    用这个脚本,可以使Unity3D窗口全屏,没有标题栏,通过更改screenPosition的值,还可以使窗口直接在第二个屏幕上启动(x=0, y=0, width=1920, height=1080),或者窗口跨越两个屏(x=0, y=0, width=3840, height=1080)。 
    Windows系统会记录每个软件的窗口大小和位置,记录在注册表的HKEY_CURRENT_USERSoftwarexxxyyy 位置,xxx是Unity3D在build设置中的Company Name,yyy是在Build设置中的Product Name。所以如果有时候窗口大小有问题,可以先备份注册表,再删除xxx项。建议每个项目的Product Name不要用默认值,否则打包出来的软件都会对应到注册表里相同的项。

  • 相关阅读:
    关于前端开发中的“收口”思想
    Ajax 完整教程(转载)
    GitHub与Git指令入门
    自制一个H5图片拖拽、裁剪插件(原生JS)
    程序猿如何“智斗”产品经理
    Spark 的调度器
    Spark shuffle 过程
    Spark on Yarn 流程
    Spark shuffle 相关参数调优
    Spark shuffle 相关参数调优(带记忆)
  • 原文地址:https://www.cnblogs.com/alps/p/5495023.html
Copyright © 2011-2022 走看看