简体   繁体   中英

With Unity Multi-display how do I change which physical monitor is associated with a Unity display?

I have three monitors. I have configured Unity to render three displays from three separate cameras attached to my primary game object, and the Unity build does render on all displays. However, the displays render in the incorrect order and in incorrect resolutions.

I've attempted to .SetRendereingResolution() using the display .systemWidth and .systemHeight for each of the three displays, but this doesn't seem to fix that one of the displays, specifically the one I have set to portrait mode, doesn't render correctly. Changing the order in which I activate the displays does not change which physical monitor they appear on.

Here's my DisplayScript.cs which is attached to my scene's main camera, and which activates the additional displays:

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()
    {

    }
}

Here's a snip of my monitor layout so that you can see screen resolution, orientation, and relative positioning , and a picture of what I see when it renders . The cube is attached to the left most camera, the sphere the right most camera .

The left most camera renders on the center display, the right most camera is rendering correctly, and the center most camera renders on the leftmost display, but does not assume a portrait resolution.

Any ideas as to how I can resolve this? Thanks!

I still don't know if it's possible to make Unity render to displays in portrait orientation but how I handled the problem was writing a Powershell script to change my monitor to landscape mode and then launch the project build. Inside the scene I rotated the camera 90*. Now it displays appropriately on my portrait-oriented display.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM