Code Monkey home page Code Monkey logo

borderlessfullscreen's Introduction

Borderless Full Screen

  • Game must be set to windowed mode for this to work properly.

-1.0.1: The mod will do this for you.

+2.0.0: Mod doesn't do this anymore to maintain compatibility with other games that can also utilize BepInEx, you can use the command below to ensure the game starts in windowed mode.

Launch Unity games in windowed mode with this command:

-screen-fullscreen 0

2.0.0+

No longer use Autohotkey.Interop dependency, instead just do what the ahk script did:

public class BorderlessFullScreenPlugin : BaseUnityPlugin
{
    [DllImport("user32.dll")]
    private static extern IntPtr FindWindow(string className, string windowName);

    [DllImport("user32.dll")]
    private static extern int GetWindowLong(IntPtr hWnd, int index);

    [DllImport("user32.dll")]
    private static extern int SetWindowLong(IntPtr hWnd, int index, int value);

    [DllImport("user32.dll")]
    private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int width, int height, uint flags);

    private const int GWL_STYLE = -16;
    private const uint SWP_FRAMECHANGED = 0x0020;
    private const uint SWP_SHOWWINDOW = 0x0040;

    private void Start()
    {
        IntPtr hWnd = FindWindow("UnityWndClass", null);
        if (hWnd != IntPtr.Zero)
        {
            int style = GetWindowLong(hWnd, GWL_STYLE);
            style &= ~0xC40000; // Remove WS_BORDER and WS_CAPTION
            SetWindowLong(hWnd, GWL_STYLE, style);

            SetWindowPos(hWnd, IntPtr.Zero, 0, 0, Screen.width, Screen.height, SWP_FRAMECHANGED | SWP_SHOWWINDOW);
        }
        else
        {
            Debug.LogError("Unity window not found.");
        }

        Debug.Log($"Plugin {"BorderlessFullscreen"} is loaded!");
    }
}

Old Description for version 1.0.1

Uses AutoHotkey.Interop to execute the following AutoHotkey script into the game through BepInEx.

procName := "UnityWndClass"
WinGet Style, Style, % "ahk_class " procName
If (Style & 0xC40000)
{
WinSet, Style, -0xC40000, % "ahk_class " procName
WinMove, % "ahk_class " procName, , 0, 0, A_ScreenWidth + 1, A_ScreenHeight + 1
}
Return

The benefit of using this is so DXVK can run... as it seems to crash the game for anything other than windowed mode.
.ahk script modified from:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.