I run a dual monitor setup (Win7), and normally when I open an application it will open in the correct place. With unity games that I create, they open directly in the middle of the two monitors, and I immediately have to drag the window to the left. Is there a way that I can set the window position of unity windows?
Yes it’s possible (on standalone Windows only). It require using external dll. You just write:
#if UNITY_STANDALONE_WIN || UNITY_EDITOR
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
private static extern bool SetWindowPos(IntPtr hwnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);
[DllImport("user32.dll", EntryPoint = "FindWindow")]
public static extern IntPtr FindWindow(System.String className, System.String windowName);
public static void SetPosition(int x, int y, int resX = 0, int resY = 0) {
SetWindowPos(FindWindow(null, "My Unity Window Title"), 0, x, y, resX, resY, resX * resY == 0 ? 1 : 0);
}
#endif
Getting window handle by window name is definitely not best way, but the easiest one.
There is no way to set the position of the window currently.