Skip to content

Commit 2c08a2c

Browse files
committed
Added documentation.
1 parent 3fe5288 commit 2c08a2c

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
- Added documentation.
89
- Added buttons on the developer console to increase/decrease the log font size.
910
- Added helper method for logging a collection in list format.
1011
- Changed command suggestions / autocomplete to also work with aliases.

DOCUMENTATION.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Documentation
2+
It is recommended to view this file in a markdown viewer, such as GitHub:
3+
4+
## Usage
5+
When the game is running, press tilde ``~`` to toggle the dev console window. The window has an input field along the bottom where commands can be entered. Pressing ENTER will execute the typed command.
6+
- Use the UP / DOWN arrows to cycle through the command history or suggested commands.
7+
- Use TAB to autocomplete a suggested command.
8+
9+
### Commands
10+
Commands are in the form: <b>commandName parameter1 parameter2 ... parameterN</b>. Some commands have no parameters!
11+
12+
Typing "<b>commands</b>" will display a list of all available commands in the console log.</br>
13+
Typing "<b>help print</b>" will provide helpful information about the <b>print</b> command.</br>
14+
Typing "<b>print "Hello world!"</b>" will display the message "Hello world!" in the console log.
15+
16+
Text that is encased by quotation marks ``"`` will be interpreted as a single parameter.
17+
18+
### Scripting
19+
The dev console can be accessed via the ``DevConsole`` static class in the ``DavidFDev.DevConsole`` namespace.
20+
- ``Enable/DisableConsole()``: enable or disable the dev console entirely (disabled by default in release builds).
21+
- ``Open/CloseConsole()``: open or close the dev console window.
22+
- ``Log()``: log a message to the dev console.
23+
- ``SetToggleKey()``: change or disable the key used to toggle the dev console window.
24+
- ``AddCommand()``: add a custom command to the dev console database.
25+
26+
#### Example
27+
```cs
28+
using DavidFDev.DevConsole;
29+
DevConsole.EnableConsole();
30+
DevConsole.SetToggleKey(null);
31+
DevConsole.Log("Hello world!");
32+
```
33+
34+
### Custom commands
35+
Custom commands can be added to the dev console by developers. They can be created in two ways:
36+
- Use ``Command.Create()`` to initialise a new command instance, allowing for multiple parameters and aliases.
37+
- Add the ``[DevConsoleCommand]`` attribute above a static method declaration, using the method body as the callback and arguments as command parameters.
38+
39+
#### Parameters
40+
Default supported parameter types implement the [``IConvertible``](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) interface (e.g. int, float, string, bool, etc.)</br>
41+
Enums are also supported.</br>
42+
Commands that use a nullable bool (``Boolean?``) parameter accept "~", "!", "null", and "toggle" - used primarily as a toggle.</br>
43+
For example, executing "<b>showfps !</b>" will toggle showing the fps on-screen.</br></br>
44+
To add a custom type, use ``DevConsole.AddParameterType<T>()`` (see FAQ below).
45+
46+
#### Example using Command.Create
47+
```cs
48+
DevConsole.AddCommand(Command.Create<string>(
49+
name: "print",
50+
aliases: "say,display",
51+
helpText: "Display a message in the dev console",
52+
p1: Parameter.Create(
53+
name: "message",
54+
helpText: "Message to display"
55+
),
56+
callback: (string message) => DevConsole.Log(message)
57+
));
58+
```
59+
60+
#### Example using attribute
61+
```cs
62+
[DevConsoleCommand(
63+
name: "print",
64+
aliases: "say,display",
65+
helpText: "Display a message in the dev console",
66+
parameterHelpText: "Message to display"
67+
)]
68+
private static void Print(string message) => DevConsole.Log(message);
69+
```
70+
71+
## Built-in commands
72+
Listed below are all the built-in commands that come with the developer console by default.
73+
74+
### Console commands
75+
- ``devconsole``: Display instructions on how to use the developer console.
76+
- ``print (String)message``: Display a message in the developer console.
77+
- ``clear``: Clear the developer console.
78+
- ``reset``: Reset the position and size of the developer console.
79+
- ``closeconsole``: Close the developer console window.
80+
- ``help (String)commandName``: Display information about a specified command.
81+
- ``enum (String)enumName``: Display information about a specified enum.
82+
- ``commands``: Display a sorted list of all available commands.
83+
- ``consoleversion``: Display the developer console version.
84+
- ``bind``: Add a key binding for a command.
85+
- ``unbind``: Remove a key binding.
86+
- ``binds``: List all the key bindings.
87+
- ``customcommands``: List all available custom commands.
88+
- ``log_size``: Query or set the font size used in the developer console log.
89+
90+
### Player commands
91+
- ``quit``: Exit the player application.
92+
- ``appversion``: Display the application version.
93+
- ``unityversion``: Display the unity version.
94+
- ``unityinput``: Display the input system being used by the developer console.
95+
- ``path``: Display the path to the application executable.
96+
- ``showfps (Boolean)enabled``: Query or set whether the fps is being displayed on-screen.
97+
98+
### Screen commands
99+
- ``fullscreen (Boolean)enabled``: Query or set whether the window is full screen.
100+
- ``fullscreen_mode (FullScreenMode)mode``: Query or set the full screen mode.
101+
- ``vsync (Int32)vSyncCount``: Query or set whether VSync is enabled.
102+
- ``resolution``: Display the current screen resolution.
103+
- ``targetfps (Int32)targetFrameRate``: Query or set the target frame rate.
104+
105+
### Camera commands
106+
- ``cam_ortho (Boolean)enabled``: Query or set whether the main camera is orthographic.
107+
- ``cam_fov (Int32)fieldOfView``: Query or set the main camera field of view.
108+
109+
### Scene commands
110+
- ``scene_load (Int32)buildIndex``: Load the scene at the specified build index.
111+
- ``scene_info (Int32)sceneIndex``: Display information about the current scene.
112+
- ``obj_info (String)name``: Display information about a game object in the scene.
113+
- ``obj_list``: Display a hierarchical list of all game objects in the scene.
114+
115+
### Log commands
116+
- ``log_logs (Boolean)enabled``: Query, enable or disable displaying Unity logs in the developer console.
117+
- ``log_errors (Boolean)enabled``: Query, enable or disable displaying Unity errors in the developer console.
118+
- ``log_exceptions (Boolean)enabled``: Query, enable or disable displaying Unity exceptions in the developer console.
119+
- ``log_warnings (Boolean)enabled``: Query, enable or disable displaying Unity warnings in the developer console.
120+
121+
### Misc commands
122+
- ``time``: Display the current time.
123+
- ``sys_info``: Display system information.
124+
- ``datapath``: Display information about where data is stored by Unity and the developer console.

DOCUMENTATION.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)