Search code examples
windowsunity-game-enginescreen-resolution

Limiting Unity windows application's resolution


I was hoping to grab some help with my problem. I want to limit my windows application window so it doesn't go under a certain resolution (example no smaller than 400x200).

I currently have logic that checks the current window size, and if its outside of a certain ratio, resize to target ratio. I can redo this logic but the problem with it is the window flickers between resolutions and its a little gross.

I want to mimic something similar to Unity editor or google chrome. There is a limit to when you try and resize the window so it doesn't go below a certain resolution.

Has anyone done something like this before and able to point me in the right direction? Sample code would also be welcomed.

Thanks!


Solution

  • Got an answer. Unity hard codes their min resoultion to 128x128. So in order to change it you need to subclass Unity's WndProc and override WM_GETMINMAXINFO window message: https://learn.microsoft.com/en-us/windows/win32/winmsg/about-window-procedures?redirectedfrom=MSDN#winproc_subclassing