Skip to content

Commit 4f170d5

Browse files
committed
Added bool? parameters to multiple commands.
1 parent f075e44 commit 4f170d5

File tree

1 file changed

+48
-18
lines changed

1 file changed

+48
-18
lines changed

Runtime/DevConsoleMono.cs

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,15 +1185,20 @@ private void InitBuiltInCommands()
11851185

11861186
#region Screen commands
11871187

1188-
AddCommand(Command.Create<bool>(
1188+
AddCommand(Command.Create<bool?>(
11891189
"fullscreen",
11901190
"",
11911191
"Query or set whether the window is full screen",
11921192
Parameter.Create("enabled", "Whether the window is full screen"),
11931193
b =>
11941194
{
1195-
Screen.fullScreen = b;
1196-
LogSuccess($"{(b ? "Enabled" : "Disabled")} fullscreen mode.");
1195+
if (!b.HasValue)
1196+
{
1197+
b = !Screen.fullScreen;
1198+
}
1199+
1200+
Screen.fullScreen = b.Value;
1201+
LogSuccess($"{(b.Value ? "Enabled" : "Disabled")} fullscreen mode.");
11971202
},
11981203
() => LogVariable("Full screen", Screen.fullScreen)
11991204
));
@@ -1261,7 +1266,7 @@ private void InitBuiltInCommands()
12611266

12621267
#region Camera commands
12631268

1264-
AddCommand(Command.Create<bool>(
1269+
AddCommand(Command.Create<bool?>(
12651270
"cam_ortho",
12661271
"",
12671272
"Query or set whether the main camera is orthographic",
@@ -1274,8 +1279,13 @@ private void InitBuiltInCommands()
12741279
return;
12751280
}
12761281

1277-
Camera.main.orthographic = b;
1278-
LogSuccess($"{(b ? "Enabled" : "Disabled")} orthographic mode on the main camera.");
1282+
if (!b.HasValue)
1283+
{
1284+
b = !Camera.main.orthographic;
1285+
}
1286+
1287+
Camera.main.orthographic = b.Value;
1288+
LogSuccess($"{(b.Value ? "Enabled" : "Disabled")} orthographic mode on the main camera.");
12791289
},
12801290
() =>
12811291
{
@@ -1494,63 +1504,83 @@ void logChildren(GameObject obj, int tabAmount)
14941504

14951505
#region Log commands
14961506

1497-
AddCommand(Command.Create<bool>(
1507+
AddCommand(Command.Create<bool?>(
14981508
"log_logs",
14991509
"",
15001510
"Query, enable or disable displaying Unity logs in the developer console",
15011511
Parameter.Create("enabled", "Whether Unity logs should be displayed in the developer console"),
15021512
b =>
15031513
{
1504-
_displayUnityLogs = b;
1505-
LogSuccess($"{(b ? "Enabled" : "Disabled")} displaying Unity logs in the developer console.");
1514+
if (!b.HasValue)
1515+
{
1516+
b = !_displayUnityLogs;
1517+
}
1518+
1519+
_displayUnityLogs = b.Value;
1520+
LogSuccess($"{(b.Value ? "Enabled" : "Disabled")} displaying Unity logs in the developer console.");
15061521
},
15071522
() =>
15081523
{
15091524
LogVariable("Log unity logs", _displayUnityLogs);
15101525
}
15111526
));
15121527

1513-
AddCommand(Command.Create<bool>(
1528+
AddCommand(Command.Create<bool?>(
15141529
"log_errors",
15151530
"",
15161531
"Query, enable or disable displaying Unity errors in the developer console",
15171532
Parameter.Create("enabled", "Whether Unity errors should be displayed in the developer console"),
15181533
b =>
15191534
{
1520-
_displayUnityErrors = b;
1521-
LogSuccess($"{(b ? "Enabled" : "Disabled")} displaying Unity errors in the developer console.");
1535+
if (!b.HasValue)
1536+
{
1537+
b = !_displayUnityErrors;
1538+
}
1539+
1540+
_displayUnityErrors = b.Value;
1541+
LogSuccess($"{(b.Value ? "Enabled" : "Disabled")} displaying Unity errors in the developer console.");
15221542
},
15231543
() =>
15241544
{
15251545
LogVariable("Log unity errors", _displayUnityErrors);
15261546
}
15271547
));
15281548

1529-
AddCommand(Command.Create<bool>(
1549+
AddCommand(Command.Create<bool?>(
15301550
"log_exceptions",
15311551
"",
15321552
"Query, enable or disable displaying Unity exceptions in the developer console",
15331553
Parameter.Create("enabled", "Whether Unity exceptions should be displayed in the developer console"),
15341554
b =>
15351555
{
1536-
_displayUnityExceptions = b;
1537-
LogSuccess($"{(b ? "Enabled" : "Disabled")} displaying Unity exceptions in the developer console.");
1556+
if (!b.HasValue)
1557+
{
1558+
b = !_displayUnityExceptions;
1559+
}
1560+
1561+
_displayUnityExceptions = b.Value;
1562+
LogSuccess($"{(b.Value ? "Enabled" : "Disabled")} displaying Unity exceptions in the developer console.");
15381563
},
15391564
() =>
15401565
{
15411566
LogVariable("Log unity exceptions", _displayUnityExceptions);
15421567
}
15431568
));
15441569

1545-
AddCommand(Command.Create<bool>(
1570+
AddCommand(Command.Create<bool?>(
15461571
"log_warnings",
15471572
"",
15481573
"Query, enable or disable displaying Unity warnings in the developer console",
15491574
Parameter.Create("enabled", "Whether Unity warnings should be displayed in the developer console"),
15501575
b =>
15511576
{
1552-
_displayUnityWarnings = b;
1553-
LogSuccess($"{(b ? "Enabled" : "Disabled")} displaying Unity warnings in the developer console.");
1577+
if (!b.HasValue)
1578+
{
1579+
b = !_displayUnityWarnings;
1580+
}
1581+
1582+
_displayUnityWarnings = b.Value;
1583+
LogSuccess($"{(b.Value ? "Enabled" : "Disabled")} displaying Unity warnings in the developer console.");
15541584
},
15551585
() =>
15561586
{

0 commit comments

Comments
 (0)