/// <summary> /// Fit the window to specified monitor /// </summary> /// <param name="monitorIndex"></param> /// <returns></returns> public bool FitToMonitor(int monitorIndex) { float dx, dy, dw, dh; if (LibUniWinC.GetMonitorRectangle(monitorIndex, out dx, out dy, out dw, out dh)) { // 最大化状態なら一度戻す if (LibUniWinC.IsMaximized()) { LibUniWinC.SetMaximized(false); } // 指定モニタ中央座標 float cx = dx + (dw / 2); float cy = dy + (dh / 2); // ウィンドウ中央を指定モニタ中央に移動 float ww, wh; LibUniWinC.GetSize(out ww, out wh); float wx = cx - (ww / 2); float wy = cy - (wh / 2); LibUniWinC.SetPosition(wx, wy); // 最大化 LibUniWinC.SetMaximized(true); //Debug.Log(String.Format("Monitor {4} : {0},{1} - {2},{3}", dx, dy, dw, dh, monitorIndex)); return(true); } return(false); }
/// <summary> /// Fit the window to specified monitor /// </summary> /// <param name="monitorIndex"></param> /// <returns></returns> public bool FitToMonitor(int monitorIndex) { float x, y, width, height; if (LibUniWinC.GetMonitorRectangle(monitorIndex, out x, out y, out width, out height)) { LibUniWinC.SetPosition(x, y); LibUniWinC.SetSize(width, height); return(true); } return(false); }
public static void DebugMonitorInfo() { int monitors = LibUniWinC.GetMonitorCount(); int currentMonitorIndex = LibUniWinC.GetCurrentMonitor(); string message = "Current monitor: " + currentMonitorIndex + "\r\n"; for (int i = 0; i < monitors; i++) { float x, y, w, h; bool result = LibUniWinC.GetMonitorRectangle(i, out x, out y, out w, out h); message += String.Format( "Monitor {0}: X:{1}, Y:{2} - W:{3}, H:{4}\r\n", i, x, y, w, h ); } Debug.Log(message); }
public bool GetMonitorRectangle(int index, out Vector2 position, out Vector2 size) { return(LibUniWinC.GetMonitorRectangle(index, out position.x, out position.y, out size.x, out size.y)); }