I guess many developers, like me, use a dual-output graphics card to make their Windows workspace extend over two monitors. I’ve been experimenting with whether it’s possible to make a Unity game that spanned two monitors (and, perhaps even more interestingly, to make a gameplay feature out of it). Here’s how:
c.) However, there’s still a problem. If you launch the app as full-screen, it will fill only one monitor. If you choose windowed mode, however, you’ll get the title bar and window edging visible in the display (even after having set a resolution that exactly fills both displays).
The solution is to use windowed mode, but to launch the application using the -popupwindow command line switch. This can easily be done by creating a batch file and launching from that instead of launching the .exe directly:
The game will now run in a borderless window that fills both screens.
d.) Now, to create the level setup that makes a gameplay feature of this. I created two orthographic cameras – Left and Right, and positioned them so that there was a slight gap between their viewing frustrums. This, in gameplay terms, represented the gap between the monitors. I then placed a large black cuboid in the gap. It would never be visible in-game, but allowed me to, e.g. fire OnTriggerEnter() calls any time a collider crossed between monitors.
Since my monitors have exactly the same resolution as each other, I want the left camera to render to the left hand-side of the game display (the left monitor), and the right camera to render to the right-hand side (the right monitor). This is easy to achieve by setting the Viewport Rect setting on the left camera to X:0 Y:0 W:0.5 H:1, and the right camera to X:0.5 Y:0 W:0.5 H:1. And then I added a little trivial logic to determine which side of the central “void” cube the player was on, and change the colour of the platforms accordingly:
And here’s what it looks like: