首页 > 解决方案 > 使用 Unity 多显示器如何更改与 Unity 显示器关联的物理显示器?

问题描述

我有三台显示器。我已将 Unity 配置为从连接到我的主要游戏对象的三个独立摄像机渲染三个显示器,并且 Unity 构建确实在所有显示器上渲染。但是,显示以不正确的顺序和不正确的分辨率呈现。

我尝试为三个显示器中的每一个使用显示 .systemWidth 和 .systemHeight 的 .SetRendereingResolution() ,但这似乎并不能解决其中一个显示器,特别是我设置为纵向模式的显示器,没有t 正确渲染。更改我激活显示器的顺序不会改变它们出现在哪个物理显示器上。

这是我的 DisplayScript.cs,它连接到我的场景的主摄像机,并激活了附加显示:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DisplayScript : MonoBehaviour
{
    // Use this for initialization
    void Start()
    {
        Debug.Log("displays connected: " + Display.displays.Length);
        // Display.displays[0] is the primary, default display and is always ON.
        // Check if additional displays are available and activate each.
        Display.displays[0].SetRenderingResolution(Display.displays[0].systemWidth, Display.displays[0].systemHeight);
        Display.displays[0].Activate();
        Debug.LogError("D0: Width " + Display.displays[0].systemWidth + " Height " + Display.displays[0].systemHeight);
        Debug.LogError("D1: Width " + Display.displays[1].systemWidth + " Height " + Display.displays[1].systemHeight);
        Debug.LogError("D2: Width " + Display.displays[2].systemWidth + " Height " + Display.displays[2].systemHeight);
        if (Display.displays.Length > 1)
        {
            Display.displays[1].SetRenderingResolution(Display.displays[1].systemWidth, Display.displays[1].systemHeight);
            Display.displays[1].Activate();

        }
        if (Display.displays.Length > 2)
        {
            Display.displays[2].SetRenderingResolution(Display.displays[2].systemWidth, Display.displays[2].systemHeight);
            Display.displays[2].Activate();
        }

    }
    // Update is called once per frame
    void Update()
    {

    }
}

这是我的显示器布局的片段,以便您可以看到屏幕分辨率、方向和相对定位,以及我在渲染时看到的图片。立方体连接到最左边的相机,球体连接到最右边的相机

最左侧的摄像头在中央显示屏上渲染,最右侧的摄像头正确渲染,最中央的摄像头在最左侧的显示屏上渲染,但不采用纵向分辨率。

关于如何解决这个问题的任何想法?谢谢!

标签: c#unity3d

解决方案


我仍然不知道是否可以让 Unity 渲染为纵向显示,但我如何处理这个问题是编写一个 Powershell 脚本将我的显示器更改为横向模式,然后启动项目构建。在场景中,我将相机旋转了 90*。现在它可以在我的纵向显示器上正确显示。


推荐阅读