Borderless unitys

Hello people,

Im looking for a sollution to have multiple unity’s running and having them borderless.
Here is a example of what i have now :

The code :

/*

 * Custom fullscreen and Borderless window script by Martijn Dekker (Pixelstudio) 

 * For questions pls contact met at martijn.pixelstudio@gmail.com 

 * version 0.1

 * 

 */



using System;

using System.Collections;

using System.Runtime.InteropServices;

using System.Diagnostics;

using UnityEngine;



public class WindowMod : MonoBehaviour

{

	public Rect screenPosition;

	

	[DllImport("user32.dll")]

	static extern IntPtr SetWindowLong (IntPtr hwnd,int  _nIndex ,int  dwNewLong);

	[DllImport("user32.dll")]

	static extern bool SetWindowPos (IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

	[DllImport("user32.dll")]

	static extern IntPtr GetForegroundWindow ();

	

	// not used rigth now

	//const uint SWP_NOMOVE = 0x2;

	//const uint SWP_NOSIZE = 1;

	//const uint SWP_NOZORDER = 0x4;

	//const uint SWP_HIDEWINDOW = 0x0080;

		

	const uint SWP_SHOWWINDOW = 0x0040;

	const int GWL_STYLE = -16;

	const int WS_BORDER = 1;

		

	void Start ()

	{

		SetWindowLong(GetForegroundWindow (), GWL_STYLE, WS_BORDER);

		bool result = SetWindowPos (GetForegroundWindow (), 0,(int)screenPosition.x,(int)screenPosition.y, (int)screenPosition.width,(int) screenPosition.height, SWP_SHOWWINDOW);

	}



}

Hi,

this might sound like a stupid question, but… What is the use of this?

erm, what if you have multiple monitors and want multiple instances of unity running… ?

why don’t you just open the application (if you’re on windows) twice, then move on to one screen, one to the other?
Not sure about macs, maybe duplicate the unity editor application, and run them both?

Not all graphics cards support two full screen apps to run on two separate monitors, so in order to run two apps in separate screens you have to run them with borders and then drag them into position. I’m guessing that with PixelStudio’s code, you can size the borderless window to the size of the monitor and then position it on each monitor. If it works, this is -very- useful, in fact, it should be part of Unity’s built in functionality! :slight_smile:

currently there is no way to run 2 or more unity’s fullscreen on two monitors.
i dont want to have the window borders around my unity and dont want to position it manualy.
Thus i tried it this way and it seems to work. as a result you can make multiple unity instances running on different monitors, and thats what i need :). cause i would like to try out creating multiple projects instead of one large unity project.

a other solution for multi monitor is using a ATI card and eyeFinity technology to have one mega large desktop streched over multiple monitors. but then only one instance of unity can run, fullscreen (this setup i have working on 5 monitors, 1 comp)

That’s exactly what I thought. This is excellent, thanks for sharing!

For those doing Macintosh. Here have a look at this.

NSWindow *win = [NSApplication sharedApplication].mainWindow;
NSRect frame = win.frame;
// Update Frame
[win setFrame:frame display:YES];
[with setStyleMask:NSBorderlessWindowMask];

Yes the message -[NSApplication mainWindow] does return the unity window.

There is only one real use for having multiple instances.

client/server versions

This doesnt belong under showcase though.

Multiple monitor support is currently only achievable via multiple instances. So there are at least two real uses.

Can’t you techincally do the following?
-adapter N

-adapter N (Windows only) Allows the game to run full-screen on another display. The N maps to a Direct3D display adaptor. In most cases there is a one-to-one relationship between adapters and video cards. On cards that support multi-head (they can drive multiple monitors from a single card) each “head” may be its own adapter.

and run one instance on one screen and the other on the other?

Source: Unity - Manual: Command-line arguments

Not sure what you mean by that… you mean a game viewport that is over two screens? I use dual monitors all the time, so you must be talking about something else.

Does someone have the modified code to have the Window in the Center?
caus thats what im looking for.
To center it and also be moveable :slight_smile: