{"id":13662287,"url":"https://github.com/stillwwater/command_terminal","last_synced_at":"2025-04-25T07:31:16.197Z","repository":{"id":33275973,"uuid":"140344763","full_name":"stillwwater/command_terminal","owner":"stillwwater","description":"Unity Command Terminal: In-Game Console","archived":false,"fork":false,"pushed_at":"2022-01-08T02:18:50.000Z","size":17045,"stargazers_count":446,"open_issues_count":18,"forks_count":60,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-11-10T17:46:55.071Z","etag":null,"topics":["unity"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stillwwater.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-09T21:36:35.000Z","updated_at":"2024-10-30T20:41:12.000Z","dependencies_parsed_at":"2022-09-02T09:22:12.293Z","dependency_job_id":null,"html_url":"https://github.com/stillwwater/command_terminal","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stillwwater%2Fcommand_terminal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stillwwater%2Fcommand_terminal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stillwwater%2Fcommand_terminal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stillwwater%2Fcommand_terminal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stillwwater","download_url":"https://codeload.github.com/stillwwater/command_terminal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250774717,"owners_count":21485209,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["unity"],"created_at":"2024-08-02T05:01:54.486Z","updated_at":"2025-04-25T07:31:16.191Z","avatar_url":"https://github.com/stillwwater.png","language":"C#","readme":"Unity Command Terminal\n======================\n\nA simple and highly performant in-game drop down Console.\n\n![gif](./demo.gif)\n\nCommand Terminal is based on [an implementation by Jonathan Blow](https://youtu.be/N2UdveBwWY4) done in the Jai programming language.\n\n## Usage\n\nCopy the contents from [CommandTerminal](./CommandTerminal) to your Assets folder. Attach a `Terminal` Component to a game object. The console window can be toggled with a hotkey (default is backtick), and another hotkey can be used to toggle the full size window (default is shift+backtick).\n\nEnter `help` in the console to view all available commands, use the up and down arrow keys to traverse the command history, and the tab key to autocomplete commands.\n\n## Registering Commands\n\nThere are 3 options to register commands to be used in the Command Terminal.\n\n### 1. Using the RegisterCommand attribute:\n\nThe command method must be static (public or non-public).\n\n```csharp\n[RegisterCommand(Help = \"Adds 2 numbers\", MinArgCount = 2, MaxArgCount = 2)]\nstatic void CommandAdd(CommandArg[] args) {\n    int a = args[0].Int;\n    int b = args[1].Int;\n\n    if (Terminal.IssuedError) return; // Error will be handled by Terminal\n\n    int result = a + b;\n    Terminal.Log(\"{0} + {1} = {2}\", a, b, result);\n}\n```\n`MinArgCount` and `MaxArgCount` allows the Command Interpreter to issue an error if arguments have been passed incorrectly, this way you can index the `CommandArg` array, knowing the array will have the correct size.\n\nIn this case the command name (`add`) will be inferred from the method name, you can override this by setting `Name` in `RegisterCommand`.\n\n```csharp\n[RegisterCommand(Name = \"MyAdd\", Help = \"Adds 2 numbers\", MinArgCount = 2, MaxArgCount = 2)]\n```\n\n### 2. Using a FrontCommand method:\n\nHere you still use the `RegisterCommand` attribute, but the arguments are handled in a separate method, prefixed with `FrontCommand`. This way, `MaxArgCount` and `MinArgCount` are automatically inferred.\n\nThis also allows you to keep the argument handling `FrontCommand` methods in another file, or even generate them procedurally during a pre-build.\n\n```csharp\n[RegisterCommand(Help = \"Adds 2 numbers\")]\nstatic void CommandAdd(int a, int b) {\n    int result = a + b;\n    Terminal.Log(\"{0} + {1} = {2}\", a, b, result);\n}\n\nstatic void FrontCommandAdd(CommandArg[] args) {\n    int a = args[0].Int;\n    int b = args[1].Int;\n\n    if (Terminal.IssuedError) return;\n\n    CommandAdd(a, b);\n}\n```\n\n### 3. Manually adding Commands:\n\n`RegisterCommand` only works for static methods. If you want to use a non-static method, you may add the command manually.\n\n```csharp\nTerminal.Shell.AddCommand(\"add\", CommandAdd, 2, 2, \"Adds 2 numbers\");\n```\n","funding_links":[],"categories":["C\\#","C#","Engines"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstillwwater%2Fcommand_terminal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstillwwater%2Fcommand_terminal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstillwwater%2Fcommand_terminal/lists"}