瀏覽代碼

Fix problems when launching game without console enabled

Bepis 6 年之前
父節點
當前提交
de90fd9ffe
共有 1 個文件被更改,包括 14 次插入11 次删除
  1. 14 11
      BepInEx/ConsoleUtil/ConsoleWindow.cs

+ 14 - 11
BepInEx/ConsoleUtil/ConsoleWindow.cs

@@ -47,18 +47,21 @@ namespace UnityInjector.ConsoleUtil
         {
             set
             {
-                if (value == null)
+                if (_attached)
                 {
-                    throw new ArgumentNullException(nameof(value));
-                }
-                if (value.Length > 24500)
-                {
-                    throw new InvalidOperationException("Console title too long");
-                }
-
-                if (!SetConsoleTitle(value))
-                {
-                    throw new InvalidOperationException("Console title invalid");
+                    if (value == null)
+                    {
+                        throw new ArgumentNullException(nameof(value));
+                    }
+                    if (value.Length > 24500)
+                    {
+                        throw new InvalidOperationException("Console title too long");
+                    }
+
+                    if (!SetConsoleTitle(value))
+                    {
+                        throw new InvalidOperationException("Console title invalid");
+                    }
                 }
             }
         }