In-game Developer Console for Unity by DavidFDev (v1.0.1).
It is recommended to view this file in a markdown viewer.
View on GitHub.
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.
- Use the UP / DOWN arrows to cycle through the command history or suggested commands.
- Use TAB to autocomplete a suggested command.
Commands are in the form: commandName parameter1 parameter2 ... parameterN. Some commands have no parameters!
Typing "commands" will display a list of all available commands in the console log.
Typing "help print" will provide helpful information about the print command.
Typing "print "Hello world!"" will display the message "Hello world!" in the console log.
Text that is encased by quotation marks "
will be interpreted as a single parameter.
The dev console can be accessed via the DevConsole
static class in the DavidFDev.DevConsole
namespace.
Enable/DisableConsole()
: enable or disable the dev console entirely (disabled by default in release builds).Open/CloseConsole()
: open or close the dev console window.Log()
: log a message to the dev console.SetToggleKey()
: change or disable the key used to toggle the dev console window.AddCommand()
: add a custom command to the dev console database.
using DavidFDev.DevConsole;
DevConsole.EnableConsole();
DevConsole.SetToggleKey(null);
DevConsole.Log("Hello world!");
Custom commands can be added to the dev console by developers. They can be created in two ways:
- Use
Command.Create()
to initialise a new command instance, allowing for multiple parameters and aliases. - Add the
[DevConsoleCommand]
attribute above a static method declaration, using the method body as the callback and arguments as command parameters.
Default supported parameter types implement the IConvertible
interface (e.g. int
, float
, string
, bool
, etc.)
To add a custom type, use DevConsole.AddParameterType<T>()
(see FAQ below).
- Enums are also supported.
- Nullable-type parameters accept "null" and "~" (e.g.
GameObject
orColor?
). - Value-type parameters accept "default" and "~" (e.g.
Int32
orColor
).
Commands that use a nullable bool (Boolean?
) are used primarily as a toggle. For example, executing "showfps ~" will toggle showing the fps on-screen.
DevConsole.AddCommand(Command.Create<string>(
name: "print",
aliases: "say,display",
helpText: "Display a message in the dev console",
p1: Parameter.Create(
name: "message",
helpText: "Message to display"
),
callback: (string message) => DevConsole.Log(message)
));
[DevConsoleCommand(
name: "print",
aliases: "say,display",
helpText: "Display a message in the dev console",
parameterHelpText: "Message to display"
)]
private static void Print(string message) => DevConsole.Log(message);
Listed below are all the built-in commands that come with the developer console by default.
devconsole
: Display instructions on how to use the developer console.print (String)message
: Display a message in the developer console.clear
: Clear the developer console.reset
: Reset the position and size of the developer console.closeconsole
: Close the developer console window.help (String)commandName
: Display information about a specified command.enum (String)enumName
: Display information about a specified enum.commands
: Display a sorted list of all available commands.consoleversion
: Display the developer console version.bind
: Add a key binding for a command.unbind
: Remove a key binding.binds
: List all the key bindings.customcommands
: List all available custom commands.log_size
: Query or set the font size used in the developer console log.
quit
: Exit the player application.appversion
: Display the application version.unityversion
: Display the unity version.unityinput
: Display the input system being used by the developer console.path
: Display the path to the application executable.showfps (Boolean)enabled
: Query or set whether the fps is being displayed on-screen.
fullscreen (Boolean)enabled
: Query or set whether the window is full screen.fullscreen_mode (FullScreenMode)mode
: Query or set the full screen mode.vsync (Int32)vSyncCount
: Query or set whether VSync is enabled.monitor_size
: Display the current monitor resolution.window_size
: Display the current window resolution.targetfps (Int32)targetFrameRate
: Query or set the target frame rate.
cam_ortho (Boolean)enabled
: Query or set whether the main camera is orthographic.cam_fov (Int32)fieldOfView
: Query or set the main camera field of view.
scene_load (Int32)buildIndex
: Load the scene at the specified build index.scene_info (Int32)sceneIndex
: Display information about the current scene.obj_info (String)name
: Display information about a game object in the scene.obj_list
: Display a hierarchical list of all game objects in the scene.
log_logs (Boolean)enabled
: Query, enable or disable displaying Unity logs in the developer console.log_errors (Boolean)enabled
: Query, enable or disable displaying Unity errors in the developer console.log_exceptions (Boolean)enabled
: Query, enable or disable displaying Unity exceptions in the developer console.log_warnings (Boolean)enabled
: Query, enable or disable displaying Unity warnings in the developer console.
cs_evaluate (String)expression
: Evaluate a C# expression or statement and display the result.cs_run (String)statement
: Execute a C# expression or statement.cs_usings
: Display a list of all active using statements.cs_vars
: Display a list of all local variables defined.cs_setusing (String)namespace (Boolean)enabled
: Set whether a using statement is included automatically when starting the developer console.cs_autousings
: Display a list of all user-defined using statements that are included automatically when starting the developer console.cs_help
: Display information about the reflection commands.
time
: Display the current time.sys_info
: Display system information.datapath
: Display information about where data is stored by Unity and the developer console.colour
: Display a colour in the developer console.