I have been trying to work this out for about an hour.
I am trying to remove the Windows border around my game launcher.
I found a blog post with a seemingly working solution but does not say anything about what actually triggers it, and the code is unnecessarily complex.
http://www.thewildeternal.com/2014/09/21/devlog-resolution-controller/
I am NOT looking to use batch files or anything like that, I want something built right into the actual Unity project.
Anyone know how to do this?
Forgot to mention this earlier but as well as having no border, I would also prefer UI transparency to work, so the launcher can be partially transparent, and preferably draggable form anywhere in the window.
Small Update: I have found something that works, it uses Windows’ User32.Dll so this is ONLY for use on Windows.
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Diagnostics;
using UnityEngine;
public class WindowBorder : MonoBehaviour
{
public Rect ScreenPosition;
public bool IsFullscreen = false;
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
[DllImport("user32.dll")]
static extern IntPtr SetWindowLong (IntPtr hwnd, int _nIndex, int dwNewLong);
[DllImport("user32.dll")]
static extern bool SetWindowPos (IntPtr hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow ();
const uint SWP_SHOWWINDOW = 0x0040;
const int GWL_STYLE = -16;
const int WS_BORDER = 1;
void Start ()
{
if(IsFullscreen)
ScreenPosition = GetFullscreenResolution();
SetWindowLong (GetForegroundWindow (), GWL_STYLE, WS_BORDER);
bool result = SetWindowPos (GetForegroundWindow (), 0, (int)ScreenPosition.x, (int)ScreenPosition.y, (int)ScreenPosition.width, (int)ScreenPosition.height, SWP_SHOWWINDOW);
}
#endif
#if UNITY_EDITOR
void Update()
{
if (IsFullscreen)
ScreenPosition = GetFullscreenResolution();
}
#endif
Rect GetFullscreenResolution()
{
Resolution resolution = Screen.currentResolution;
return new Rect(0f, 0f, (float)resolution.width, (float)resolution.height);
}
}
If anyone works out how to drag this around (with left or right click for example) please let me know.