✅ Verified as working in versions 2020.3.1f1 and 2020.3.18f1 of Unity
Import DevConsoleTool.unitypackage
into your Unity project.
Scripts: Contains the code that will be run whenever your command is run from the console.
Commands: Scriptable objects that store the command name and description.
CommandCollection: A singular scriptable object that holds a list of all saved commands.
ConsoleManager: The script that handles input and output for your in-game console
- The whole console is based around two UI elements: one Text object and one InputField object.
- The Text object will be used for the console’s history log.
- The InputField will be used as the entry field for inputting commands.
- Once you’ve set up your UI elements, attach the ConsoleManager script to an object in your scene. This doesn’t have to be on a UI layer, it can even be on an empty GameObject.
- Plug in your Text and InputField objects into the ConsoleManager script
- Set History Length to the number of lines tall you want your history log to be
- Set “Command Collection” to the CommandCollection scriptable object that came included with the DevConsole. (located at
DevConsole/_ConsoleOperation/CommandCollection.asset
) - That’s it. Now you can start creating your commands!
- Open the Console Tool window (Tools > Console Tool Window)
- In the script column, look for the text entry field labeled “Create new script”.
- Type a name for your script into the entry field. Then click the “+” button. (Note: a “cmd_” prefix will be added to your script name)
- Unity will focus on the new file that is being created. To complete the creation process either press the enter key or click anywhere on the Console Tool window.
- The console tool may take a second for the ui to show the newly created file.
- Open your script in an IDE.
- The Process function is called whenever your command is run via the in-game console. This is where you can code whatever functionality you want.
- The “args” string array contains any strings that followed the initial command name when the command was called (args are acquired by splitting the player’s input string on spaces).
- Open the Console Tool window (Tools > Console Tool Window)
- In the script column select the script that you want to be called whenever your command will be run.
- Now click the “+ new command” button.
- A new entry should appear in the Commands column with the label “[no name]”. This is your new command. Click on it.
- After selecting your new command, edit its name and description using the Details panel.
- After you’ve entered your name and description, click the save button in the bottom right.