Skip to content

Instantly share code, notes, and snippets.

@sdelrue
Last active May 16, 2024 06:26
Show Gist options
  • Save sdelrue/b9eaf57f7e0dd55ddaa758186895d351 to your computer and use it in GitHub Desktop.
Save sdelrue/b9eaf57f7e0dd55ddaa758186895d351 to your computer and use it in GitHub Desktop.
This minizes the Unity window (Editor or Build) from code. Only tested on windows.
using UnityEngine;
using System.Runtime.InteropServices;
public class Minimize : MonoBehaviour {
private void OnMimize() {
ShowWindow(GetActiveWindow(), 2);
}
[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll")]
private static extern IntPtr GetActiveWindow();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment