After trying to switch to a modern Version of Unity we encountered into a blocking bug since Unity 2018.3. The bug is also present in the latest Version 2019.1.0f2.
I work with Unity for a few years and i created many dirty fixes for bugs in the Unity engine (we used 5.6.6 a long time) but this time it is different. There is a ‘bug’ in the current versions where you cannot switch to a maximized window without entering fullscreen mode. This is very annoying if you want to create special 2D viewer or a tool in general - not a game. (see the bug Unity Issue Tracker - Fullscreen mode: Maximized Window functionality is broken and any built Player changes to Non-Window mode when Maximizing)
This worked in previous versions. Now Unity say ‘Maximized window mode is not supported in the windows player’. Maybe they have a good reason for this or maybe this is an oversight. I know. I’m doing this at my own risk.
I did a lot of research and found the problem. I debugged my application using the provided PDB files for the UnityPlayer.dll and found the fullscreen call in the WM_SIZE event from the Win32 api. I tried to hook into the windows events and reject the maximized event so the Unity engine cannot react this event anymore (i’m doing this at my own risk).This did not work. You cannot reject an windows message event that easily.
My next thought was, what if i could block this call inside the engine itself. I tried changed a single byte in the right place and now … it just works!
But am i allowed to do that? The software terms say am not allow to modify any part of the Unity Software. Is the player part of the ‘Unity Software’?
Unity Software Additional Terms: https://unity3d.com/de/legal/terms-of-service/software
I also could compile my own Player.exe, loading the UnityPlayer.dll and overwriting the function call in memory. Would that make any different?
PS.: I will post this dirty dirty hot-fix if it is allowed by the software terms.
Edit: Changed UnityEngine.dll to UnityPlayer.dll