More control over Windowed Unity apps?

Hello,
Is there a way to have make windowed and resizable applications in Unity without having to use the standard title bar? A solution that works on Windows, Mac and Linux?

Thanks in advance!

/Andreas

I don’t think that there is any simple way to do this cross-platform.

On Windows it’s easy as you can just use the functions in the User32.dll.
On Mac it looks like it’s possible, but quite a bit more complicated.
On Linux… well… good luck. Pretty much everyone uses a different Linux distribution and a different window manager. Some allow hiding title bars, others don’t. Some provide an API to interact with windows, others don’t. If you don’t target a specific OS with a specific window manager it’s probably not worth the effort.

That’s disappointing.
Seems like a function to hide the title bar should be included in Unity, if you want to make any type of desktop application with custom design. I’ve used Adobe AIR for this in the past and they have great cross platform support for making your own window styles.

There is a way to embed the engine into a normal app window but it’s not available on macOS and Linux.

https://docs.unity3d.com/Manual/UnityasaLibrary.html
https://github.com/Unity-Technologies/uaal-example

I didn’t bother searching for this one as it’s well documented but kinda buried which is an excellent use case for ChatGPT. I haven’t verified the code but it looks correct. Win32 is very easy to work with.

GPT-4 Code

using UnityEngine;
using System.Runtime.InteropServices;

public class HideTitleBar : MonoBehaviour
{
    [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
    private static extern System.IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true)]
    private static extern int SetWindowLong(System.IntPtr hwnd, int nIndex, int dwNewLong);

    [DllImport("user32.dll", SetLastError = true)]
    private static extern int GetWindowLong(System.IntPtr hwnd, int nIndex);

    [DllImport("user32.dll")]
    static extern bool SetWindowPos(System.IntPtr hWnd, System.IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);

    const uint SWP_FRAMECHANGED = 0x0020;
    const uint SWP_NOMOVE = 0x0002;
    const uint SWP_NOSIZE = 0x0001;
    const uint SWP_NOZORDER = 0x0004;

    const int GWL_STYLE = -16;
    const int WS_CAPTION = 0x00C00000;

    void Start()
    {
        string windowName = Application.productName;
        System.IntPtr hwnd = FindWindow(null, windowName);

        if (hwnd != System.IntPtr.Zero)
        {
            int style = GetWindowLong(hwnd, GWL_STYLE);
            SetWindowLong(hwnd, GWL_STYLE, (style & ~WS_CAPTION));
            SetWindowPos(hwnd, System.IntPtr.Zero, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
        }
    }
}

Someone posted a macOS implementation last year that was fairly simple.

https://discussions.unity.com/t/754827/32