使用Unity Multi-display,如何更改与Unity显示器关联的物理监视器?

时间:2019-06-11 06:39:38

标签: c# unity3d

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

我已经尝试为三个显示器中的每一个使用显示.systemWidth和.systemHeight来.SetRendereingResolution(),但这似乎并不能解决其中一个显示问题,特别是我已将其设置为纵向模式的问题。 ,无法正确呈现。更改我激活显示器的顺序不会改变它们出现在哪个物理监视器上。

这是我的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()
    {

    }
}

这里是snip of my monitor layout so that you can see screen resolution, orientation, and relative positioningpicture of what I see when it renderscube is attached to the left most camera, the sphere the right most camera

最左边的相机在中央显示屏上渲染,最右边的相机在正确渲染,最中央的相机在最左边的显示屏上渲染,但不采用纵向分辨率。

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

1 个答案:

答案 0 :(得分:0)

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

相关问题