c# - Add screen modes in settings -
i've created ui options menu graphics , screen. thing able add obly boolean value fullscreen mode. need add dropdown 3 modes: fullscreen, windowed, , windowed no frame (stretched entire screen size). how third mode?
check out this sample code. uses user32.dll
library, though, need reference in project.
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 //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); }
with method best bet to:
- create enum options, example
public enum windowmode { fullscreen, borderless, window }
- create manager class method takes enum argument:
public void setwindowmode(windowmode wm // or int) {...}
- wire method called whenever item selected combobox on options menu uui's
eventsystem
thingy - that's pretty it.
Comments
Post a Comment