Skip to content

Commit 520f0d7

Browse files
committed
Add Debug Commands docs
1 parent 93405de commit 520f0d7

File tree

7 files changed

+112
-0
lines changed

7 files changed

+112
-0
lines changed

manual/editor/windows/output-log.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@
55
The **Output Log** is a utility window that displays the current engine log. Can be used to detect problems with the game or to analyze the engine workload.
66

77
You can easily select and copy parts of the log, use the *Search* box to filter entries or use the log types filter under the **View** dropdown menu. Also, loading log files is supported which can be used to read and analyze the logs from the build version of the game (eg. from Xbox dev build).
8+
9+
### Debug Commands
10+
11+
![Debug Commands in Output Log](../../scripting/advanced/media/debug-commands-output-log.gif)
12+
13+
At the bottom of that window, there is an input command field that can be used to run [Debug Commands](../../scripting/advanced/debug-commands.md). You can type commands with an automatic search popup that displays similar commands based on the entered value. Use arrow keys to navigate around that popup list. The tab key can be used to autocomplete commands based on the best-found match. Finally, when input is empty you can use the arrow up key to navigate around the command history and re-try one of them again.
+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Debug Commands
2+
3+
`DebugCommand` is an attribute that can be placed on classes, fields, methods, and properties to expose them to Debug Commands interface which can be used for configuration, modding, or tooling.
4+
5+
> [!TIP]
6+
> Only `static` members can be used in debug commands.
7+
8+
## Access
9+
10+
### Output Log
11+
12+
![Debug Commands in Output Log](media/debug-commands-output-log.gif)
13+
14+
[Output Log](../../editor/windows/output-log.md) is Editor window that displays the full log. At the bottom of that window, there is an input command field that can be used to run commands. You can type commands with an automatic search popup that displays similar commands based on the entered value. Use arrow keys to navigate around that popup list. The tab key can be used to autocomplete commands based on the best-found match. Finally, when input is empty you can use the arrow up key to navigate around the command history and re-try one of them again.
15+
16+
### In-game console
17+
18+
![Debug Commands In Game](media/debug-commands-in-game.png)
19+
20+
Debug Commands can appear within an in-game console or debug tooling. For example, [Arizona Framework](https://github.com/FlaxEngine/ArizonaFramework) implements console via [ImGui](https://github.com/FlaxEngine/ImGui). Such tool can be useful when developing games for various platforms and devices such as consoles where game configurations can be tweaked at runtime.
21+
22+
### `DebugCommands` API
23+
24+
Use `DebugCommands` class to execute or list debug commands within the project. It caches all commands for engine, game, and plugin projects.
25+
26+
Example usage:
27+
28+
# [C#](#tab/code-csharp)
29+
```cs
30+
// Disable vsync
31+
DebugCommands.Execute("Graphics.UseVSync false");
32+
```
33+
# [C++](#tab/code-cpp)
34+
```cpp
35+
// Disable vsync
36+
DebugCommands::Execute(TEXT("Graphics.UseVSync false"));
37+
```
38+
***
39+
40+
## Example
41+
42+
# [C#](#tab/code-csharp)
43+
```cs
44+
using FlaxEngine;
45+
46+
/// <summary>
47+
/// Global gameplay configs.
48+
/// </summary>
49+
[DebugCommand]
50+
public static class GameGlobals
51+
{
52+
/// <summary>
53+
/// Disables player damage.
54+
/// </summary>
55+
public static bool GodMode = false;
56+
}
57+
58+
/// <summary>
59+
/// Player script.
60+
/// </summary>
61+
public class PlayerLogic : Script
62+
{
63+
/// <summary>
64+
/// Player speed scale.
65+
/// </summary>
66+
[DebugCommand]
67+
public static float SpeedScale = 1.0f;
68+
69+
/// <summary>
70+
/// Restores player HP to max.
71+
/// </summary>
72+
[DebugCommand]
73+
public static void HealPlayer()
74+
{
75+
//..
76+
}
77+
}
78+
```
79+
# [C++](#tab/code-cpp)
80+
```cpp
81+
// Global gameplay configs.
82+
API_CLASS(Static, Attributes="DebugCommand") class GAME_API GameGlobals
83+
{
84+
DECLARE_SCRIPTING_TYPE_NO_SPAWN(GameGlobals);
85+
public:
86+
// Disables player damage.
87+
API_FIELD() static bool GodMode;
88+
};
89+
90+
// Player script.
91+
API_CLASS() class GAME_API PlayerLogic : public Script
92+
{
93+
API_AUTO_SERIALIZATION();
94+
DECLARE_SCRIPTING_TYPE(PlayerLogic);
95+
public:
96+
// Player speed scale.
97+
API_FIELD(Attributes="DebugCommand") static float SpeedScale;
98+
99+
// Restores player HP to max.
100+
API_FUNCTION(Attributes="DebugCommand") static void HealPlayer();
101+
};
102+
```
103+
***

manual/scripting/advanced/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
* [Tags](tags.md)
1717
* [Run code on module load](code-on-load.md)
1818
* [File Reference](file-reference.md)
19+
* [Debug Commands](debug-commands.md)
Loading
Loading

manual/scripting/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ To start visual scripting see the related documentation [here](visual/index.md).
9191
* [Tags](advanced/tags.md)
9292
* [Run code on module load](advanced/code-on-load.md)
9393
* [File Reference](advanced/file-reference.md)
94+
* [Debug Commands](advanced/debug-commands.md)
9495
* [Artificial Intelligence](ai/index.md)
9596
* [Behavior Trees](ai/behavior-trees/index.md)
9697
* [Behavior Knowledge](ai/behavior-trees/knowledge.md)

manual/toc.md

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
### [Tags](scripting/advanced/tags.md)
218218
### [Run code on module load](scripting/advanced/code-on-load.md)
219219
### [File Reference](scripting/advanced/file-reference.md)
220+
### [Debug Commands](scripting/advanced/debug-commands.md)
220221
## [Artificial Intelligence](scripting/ai/index.md)
221222
### [Behavior Trees](scripting/ai/behavior-trees/index.md)
222223
#### [Behavior Knowledge](scripting/ai/behavior-trees/knowledge.md)

0 commit comments

Comments
 (0)