Commands
The ConsoleGameExampleConfig asset in the CosmosConsole/Examples/Configs/ directory is used by the console in the sample scene. The commands are divided in several categories. The code for handling these commands is explained in the Utility Scripts section.
Built-in
The built-in commands are not necessary for the console to work, but they can be very useful. When creating a new CosmosConsoleConfig asset you can add the definitions for these commands with a single button press. To hook up the script handlers, simply call the following method on your console instance:
console.SetupBuiltInCommands();
The built-in commands are:
help: prints all the available commands, grouped by category, along with their descriptions
- option parameter: if set to "nodesc", will leave out the descriptions of the commands to make it easier to read the list at a glance
cosmos_connect: connect to a remote server console. Only available on client consoles.
- host parameter: the host address to the server console.
- user parameter: the username to use for the server login.
- pass parameter: the password to use for the server login.
- cosmos_disconnect: disconnect from the remote server console.
- cosmos_client_status: prints the client connection status to console output.
- cosmos_remote_enable: enables the server-mode of the console, after which client consoles can connect.
- port parameter: the network port that the server console will use.
- cosmos_remote_disable: disables the server-mode and disconnects any connected clients.
- cosmos_remote_list_clients: outputs the list of clients that are currently connected to this server console.
- cosmos_server_status: prints the server connection status console output.
- cosmos_discover: outputs a list of all the server consoles active on the local area network (which you can then potentially connect to using cosmos_connect).
- port parameter: the network port to scan for,
- timeout parameter: how long to wait for responses from the local network.
- exec: executes the commands listed in a file (on the local user's storage). The list of commands is delimited by newlines.
- file parameter: the filename. The file should be located in one of the configured folders. Can be written with or without the .cfg extension.
You have to configure the folders that the exec command uses to look for the file to execute. You can do so using the following call:
console.SetExecCommandFilePaths(new string[] { path1, path2, etc });
Debugging
This is a category of commands that can assist developers with debugging their game.
- debuglog_echo: echoes the Unity console output to the Cosmos Console output. Useful for connected clients to monitor for errors or other debug log prints.
- filter1 parameter: filter the type of logs it should echo. Accepts the values "logs", "warnings" or "errors".
- filter2 parameter: filter the type of logs it should echo. Accepts the values "logs", "warnings" or "errors".
- debuglog_echo_stop: stop echoing Unity console output to the Cosmos Console output, if it was active.
- scenehierarchy_print: outputs the GameObject hierarchy of the currently opened scenes.
- systeminfo_print: outputs hardware and software properties like CPU, GPU, and others of the current device.
- playerprefs_string: set / get the specified player preference setting.
- key parameter: the player preference key string.
- string parameter: the string value to set it to. If not specified, the command will simply output the current value of the setting.
- playerprefs_int: set / get the specified player preference setting.
- key parameter: the player preference key string.
- int parameter: the integer value to set it to. If not specified, the command will simply output the current value of the setting.
- playerprefs_float: set / get the specified player preference setting.
- key parameter: the player preference key string.
- string parameter: the float value to set it to. If not specified, the command will simply output the current value of the setting.
- performance_monitor_start: outputs the average framerate and memory usage of the game at a repeating interval.
- interval parameter: the interval in seconds at which the performance report is printed.
- performance_monitor_stop: stop outputting performance reports.
GameObjects
This is a category of generic commands that focus on adjusting Game Objects in the scene. They're also a good example of commands that remember a state, in this case the Game Objects you have 'selected'.
- objects_select_name: select all the Game Objects in the scene that match this name.
- name parameter: the name string to match.
- stringmatch parameter: the type of matching to perform. Accepts the values "equals", "caseinsensitive" or "contains".
- objects_select_tag: select all the Game Objects in the scene with a matching tag.
- tag parameter: the tag to match.
- objects_filter_name: filters out all the Game Objects in the current selection that do not match this name.
- name parameter: the name string to match.
- stringmatch parameter: the type of matching to perform. Accepts the values "equals", "caseinsensitive" or "contains".
- objects_filter_tag: filters out all the Game Objects in the current selection that do not have this tag.
- tag parameter: the tag to match.
- objects_filter_remove: filters out the Game Object at the specified index (as shown in the selection list) from the selection.
- index parameter: the index of the Game Object to remove from the selection.
- objects_status: print out the list of selected objects with some general information.
- objects_set_active: activate or deactivate all the selected Game Objects.
- active parameter: boolean value determining whether to activate or deactiveate.
- objects_instantiate: instantiates copies of the current selection of objects.
- x, y, z, pitch, yaw roll parameters: sets the position and rotation of the newly created objects.
- objects_destroy: destroys the Game Objects in the selection.
- objects_position: sets the position of the Game Objects in the current selection.
- x, y, z parameters: the position values to set.
- objects_rotation: sets the rotation of the Game Objects in the current selection.
- pitch, yaw, roll parameters: the (euler) rotation values to set.
- objects_scale: sets the scale of the Game Objects in the current selection.
- x, y, z parameters: the scale along every dimension to set.
Game
This is a category of commands specific to the game in the sample scene.
- restart: restarts the scene.
- kill_all: destroys all the current 'chompers' in the scene.
- timescale: sets the timescale of the game.
- value parameter: number value.
- player_speed: sets the movement speed of the player. Default value is 5.
- value parameter: number value.
- player_jumpforce: sets the jump force of the player, which determines how high you'll jump. Default value is 10.
- value parameter: number value.
- weapon_automatic: sets whether the player weapon is fully automatic. Default is false.
- value parameter: boolean value.
- weapon_fireinterval: sets the firing interval of the weapon, which is the same as (1 / weapon fire rate). Default value is 0.1
- value parameter: number value.
- enemy_speed: sets the movement speed of the enemy chompers.
- value parameter: number value.
- enemy_spawninterval: sets the interval between enemy spawns.
- value parameter: number value.
- open_gate: opens or closes one of the dynamic gates in the scene based on the tag.
- tag parameter: the tag string of the gate to match. The autocomplete should suggest available tags. This is an example of adding parameter values during runtime based on your scene content.