Nain
Nain

Reputation: 1232

Unity Multiple displays not working

I am using Unity 5.4.1f1 personal edition and working on Windows standalone build. I want to use multiple displays in my game. I have 2 cameras and set the target display of one camera to display 1 and target display of second camera to display 2.

Also, I have activated the display but Display.displays.Length is always one on editor as well as on build.

So it does not display anything on the second screen. What should I do to display on second screen?

Upvotes: 3

Views: 12926

Answers (3)

Nain
Nain

Reputation: 1232

This bug was in unity 5.4.1 i have tested with unity 5.6.1f1 and above unity multiple displays works just fine there is no need of expanding screen or setting parameters just need to activate the displays and set the target display property of camera

Unity documentation is a bit ambiguous about this feature.

Also Display.displays.Length always return 1 in editor mode but in build it works fine.

I have found a solution to this problem reference to post http://answers.unity3d.com/questions/309819/getting-unity-to-render-across-multiple-monitors.html. That is we have to call Screen.SetResolution(sum of width of all displays , height, false); the false is because we do not want to render in fullscreen mode. This is because unity does not creates multiple windows it only create one window we have to extend it to match the resolution of multiple displays.

Activate the aditional displays by calling Activate() and aslo set the setparams to give the each display a starting value. I worked it out for 3 displays.

if (Display.displays.Length > 1)
{
 //display 0 is set by default
    Display.displays[1].Activate();
    Display.displays[1].SetParams(Width of display 1,height of display 1,starting x for display 1,starting y for display 1);
}
if (Display.displays.Length > 2)
{
    Display.displays[2].Activate();
    Display.displays[2].SetParams(Width of display 2,height of display 2,starting x for display 2,starting y for display 2);
}

In the build setting set 'Display Resolution Dialog' to 'Disabled' make sure 'Default Is Full Screen' is NOT checked.

Create the build and then there is a final step run the exe wtih -popupwindow or -multidisplay command line argument.

If it still not worked open your screen resolution dialog and verify the positioning of monitors.

It works good but it produces fish eye effect.

Upvotes: 4

Programmer
Programmer

Reputation: 125435

What you see is actually bug. Don't waste your time trying to fix it. Go to Help --> Report a Bug... then report the problem. There are many bug reports open for this problem but it's a good idea to file for another one to remind them that this is still not fixed.

Here are bug reports on this. Unity claims to have fixed this on some of them but that's not true because I was able to reproduce this problem with my computer with Unity 5.6. Bug Report 1, Bug Report 2 and Bug Report 3.

Upvotes: 4

You need to activate each additional display in code with Display.Activate.

See the docs where it says:

The best time to activate additional displays is upon creating a new Scene. A good way to do this is to attach a script component to the default Camera. Make sure you call Display.Activate only once during the startup. You may find it helpful to create a small initial scene to test it.

And from the example, in the Start() Method:

if (Display.displays.Length > 1)
    Display.displays[1].Activate();
if (Display.displays.Length > 2)
    Display.displays[2].Activate();

Note: Once a monitor has been activated, you cannot deactivate it.

Upvotes: 5

Related Questions