2011
06.20
06.20
Here is a quick script to get unity borderless
Press read more for the code
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
/* * Custom fullscreen and Borderless window script by Martijn Dekker (Pixelstudio) * For questions pls contact met at martijn.pixelstudio@gmail.com * version 0.1 * */ using System; using System.Collections; using System.Runtime.InteropServices; using System.Diagnostics; using UnityEngine; public class WindowMod : MonoBehaviour { public Rect screenPosition; [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 (); // not used rigth now //const uint SWP_NOMOVE = 0x2; //const uint SWP_NOSIZE = 1; //const uint SWP_NOZORDER = 0x4; //const uint SWP_HIDEWINDOW = 0x0080; const uint SWP_SHOWWINDOW = 0x0040; const int GWL_STYLE = -16; const int WS_BORDER = 1; void Start () { 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); } } |
This is really usefull!!!
Unfortunately it seems, that this doesnt work, when you want to switch between fullscreen- and windowed- mode. Whenn “comming back” from full-screen the window again has its borders and looses the position.
Is there a possibility to make that work too??
Best regards, Josef!
true, you have to run the function every time you change from fullscreen.
Be aware that this is not true fullscreen, i have no idea how this affects preformance.
hey martijn,
Is there a way to reset it so it has window border?
Greetz
Robert
PS:
Is there a way to make parts transparent like old unity startup had or other applications (like cutouts)…?
PSPS: where did u get the information about that?
Greetz
Robert
hey 2 updates for you all
NEVER RUN THE SCENE IN EDITOR !!!! XD
–> the border is hidden there too
it works fine on 64 bit and i dunno if it was smthng wrnog but without border it ran faster than with…..maybe the aero effect?
greetz
Robert
again its me, i use this to make a cutout in the window where color is black but it doesnt work, any help?
SetWindowLong(GetForegroundWindow (), GWL_EXSTYLE, WS_EX_LAYERED);
SetWindowLong(GetForegroundWindow (), GWL_STYLE, WS_BORDER);
SetLayeredWindowAttributes(GetForegroundWindow (), 0, 0, LWA_COLORKEY);
Thank you, this inspired me to make a my own borderless maximized windowed mode class. My version supports multiple monitors, and has keeping the taskbar visible as an optional behavior.
Share it man!
martijn may u take a look at the cutout thing pls?
@Robert Schuh:
This is nothing special. It’s just plain windows API stuff
What you want is to set a window region i guess. You can do funny things with it. What exactly do you want to cut out?
http://msdn.microsoft.com/en-us/library/aa930600.aspx
You can also use the -popupwindow commandline parameter to create a borderless window:
http://docs.unity3d.com/Documentation/Manual/CommandLineArguments.html