{"id":13662916,"url":"https://github.com/yasirkula/UnityIngameDebugConsole","last_synced_at":"2025-04-25T13:30:30.679Z","repository":{"id":37546025,"uuid":"61235116","full_name":"yasirkula/UnityIngameDebugConsole","owner":"yasirkula","description":"A uGUI based console to see debug messages and execute commands during gameplay in Unity","archived":false,"fork":false,"pushed_at":"2024-10-27T11:37:53.000Z","size":6613,"stargazers_count":2163,"open_issues_count":6,"forks_count":225,"subscribers_count":42,"default_branch":"master","last_synced_at":"2024-10-28T13:25:59.769Z","etag":null,"topics":[],"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/yasirkula.png","metadata":{"files":{"readme":".github/README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"yasirkula","custom":"https://yasirkula.itch.io/unity3d/donate"}},"created_at":"2016-06-15T19:29:18.000Z","updated_at":"2024-10-28T09:49:12.000Z","dependencies_parsed_at":"2023-02-08T06:16:27.526Z","dependency_job_id":"a42462d9-c4a9-47d4-a738-3d9234c0f1a4","html_url":"https://github.com/yasirkula/UnityIngameDebugConsole","commit_stats":null,"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasirkula%2FUnityIngameDebugConsole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasirkula%2FUnityIngameDebugConsole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasirkula%2FUnityIngameDebugConsole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasirkula%2FUnityIngameDebugConsole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yasirkula","download_url":"https://codeload.github.com/yasirkula/UnityIngameDebugConsole/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224003721,"owners_count":17239495,"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":[],"created_at":"2024-08-02T05:02:12.022Z","updated_at":"2024-11-10T19:30:29.232Z","avatar_url":"https://github.com/yasirkula.png","language":"C#","readme":"# In-game Debug Console for Unity 3D\n\n\u003cimg height=\"235\" src=\"Images/1.png\" alt=\"screenshot\" /\u003e \u003cimg height=\"235\" src=\"Images/2.png\" alt=\"screenshot2\" /\u003e\n\n**Available on Asset Store:** https://assetstore.unity.com/packages/tools/gui/in-game-debug-console-68068\n\n**Forum Thread:** http://forum.unity3d.com/threads/in-game-debug-console-with-ugui-free.411323/\n\n**Discord:** https://discord.gg/UJJt549AaV\n\n**[GitHub Sponsors ☕](https://github.com/sponsors/yasirkula)**\n\n## ABOUT\n\nThis asset helps you see debug messages (logs, warnings, errors, exceptions) runtime in a build (also assertions in editor) and execute commands using its built-in console. It also supports logging *logcat* messages to the console on Android platform.\n\nUser interface is created with **uGUI** and costs **1 SetPass call** (and 6 to 10 batches) when *Sprite Packing* is enabled. It is possible to resize or hide the console window during the game. Once the console is hidden, a small popup will take its place (which can be dragged around). The popup will show the number of logs that arrived since it had appeared. Console window will reappear after clicking the popup.\n\n![popup](Images/3.png)\n\nConsole window is optimized using a customized recycled list view that calls *Instantiate* function sparingly. \n\n## INSTALLATION\n\nThere are 5 ways to install this plugin:\n\n- import [IngameDebugConsole.unitypackage](https://github.com/yasirkula/UnityIngameDebugConsole/releases) via *Assets-Import Package*\n- clone/[download](https://github.com/yasirkula/UnityIngameDebugConsole/archive/master.zip) this repository and move the *Plugins* folder to your Unity project's *Assets* folder\n- import it from [Asset Store](https://assetstore.unity.com/packages/tools/gui/in-game-debug-console-68068)\n- *(via Package Manager)* add the following line to *Packages/manifest.json*:\n  - `\"com.yasirkula.ingamedebugconsole\": \"https://github.com/yasirkula/UnityIngameDebugConsole.git\",`\n- *(via [OpenUPM](https://openupm.com))* after installing [openupm-cli](https://github.com/openupm/openupm-cli), run the following command:\n  - `openupm add com.yasirkula.ingamedebugconsole`\n\n## FAQ\n\n- **New Input System isn't supported on Unity 2019.2.5 or earlier**\n\nAdd `ENABLE_INPUT_SYSTEM` compiler directive to **Player Settings/Scripting Define Symbols** (these symbols are platform specific, so if you change the active platform later, you'll have to add the compiler directive again).\n\n- **\"Unity.InputSystem\" assembly can't be resolved on Unity 2018.4 or earlier**\n\nRemove `Unity.InputSystem` assembly from **IngameDebugConsole.Runtime** Assembly Definition File's *Assembly Definition References* list.\n\n- **\"Receive Logcat Logs In Android\" isn't working, it says \"java.lang.ClassNotFoundException: com.yasirkula.unity.DebugConsoleLogcatLogger\" in Logcat**\n\nIf you are sure that your plugin is up-to-date, then enable **Custom Proguard File** option from *Player Settings* and add the following line to that file: `-keep class com.yasirkula.unity.* { *; }`\n\n## HOW TO\n\nSimply place **IngameDebugConsole** prefab to your scene. Hovering the cursor over its properties in the Inspector will reveal explanatory tooltips.\n\nWhile testing on Unity editor, right clicking a log entry will open the corresponding line in external script editor, similar to double clicking a log in Unity Console.\n\n## COMMAND CONSOLE\n\n### Executing Commands\n\nYou can enter commands using the input field at the bottom of the console. To see all available commands, simply type \"*help*\".\n\nA command is basically a function that can be called from the console via the command input field. This function can be **static** or an **instance function** (non static), in which case, a living instance is required to call the function. The return type of the function can be anything (including *void*). If the function returns an object, it will be printed to the console. The function can also take any number of parameters; the only restriction applies to the types of these parameters. Supported parameter types are:\n\n**Primitive types, enums, string, Vector2, Vector3, Vector4, Color, Color32, Vector2Int, Vector3Int, Quaternion, Rect, RectInt, RectOffset, Bounds, BoundsInt, GameObject, any Component type, arrays/Lists of these supported types**\n\nNote that *GameObject* and *Component* parameters are assigned value using *GameObject.Find*.\n\nTo call a registered command, simply write down the command and then provide the necessary parameters. For example: \n\n`cube [0 2.5 0]`\n\nTo see the syntax of a command, see the help log:\n\n`- cube: Creates a cube at specified position -\u003e TestScript.CreateCubeAt(Vector3 position)`\n\nHere, the command is *cube* and it takes a single *Vector3* parameter. This command calls the *CreateCubeAt* function in the *TestScript* script (see example code below for implementation details).\n\nConsole uses a simple algorithm to parse the command input and has some restrictions:\n\n- Wrap strings with quotation marks ( \" or ' )\n- Wrap vectors with brackets ( \\[\\] ) or parentheses ( () )\n\nHowever, there is some flexibility in the syntax, as well:\n\n- You can provide an empty vector to represent Vector_.zero: \\[\\]\n- You can enter 1 instead of true, or 0 instead of false\n- You can enter `null` for null GameObject and/or Component parameters\n\n### Registering Custom Commands\n\nIf all the parameters of a function are of supported types, you can register the function to the console in four different ways (all of these methods take optional string parameter(s) at the end to specify custom display names for the registered function's parameter(s)):\n\n- **ConsoleMethod Attribute** *(not supported on UWP platform)*\n\nSimply add **IngameDebugConsole.ConsoleMethod** attribute to your functions. These functions must be *public static* and must reside in a *public* class. These constraints do not apply to the other 3 methods.\n\n```csharp\nusing UnityEngine;\nusing IngameDebugConsole;\n\npublic class TestScript : MonoBehaviour\n{\n\t[ConsoleMethod( \"cube\", \"Creates a cube at specified position\" )]\n\tpublic static void CreateCubeAt( Vector3 position )\n\t{\n\t\tGameObject.CreatePrimitive( PrimitiveType.Cube ).transform.position = position;\n\t}\n}\n```\n\n- **Strongly Typed Functions**\n\nUse one of the `DebugLogConsole.AddCommand( string command, string description, System.Action method )` variants:\n\n```csharp\nusing UnityEngine;\nusing IngameDebugConsole;\n\npublic class TestScript : MonoBehaviour\n{\n\tvoid Start()\n\t{\n\t\tDebugLogConsole.AddCommand( \"destroy\", \"Destroys \" + name, Destroy );\n\t\tDebugLogConsole.AddCommand\u003cVector3\u003e( \"cube\", \"Creates a cube at specified position\", CreateCubeAt );\n\t\tDebugLogConsole.AddCommand\u003cstring, GameObject\u003e( \"child\", \"Creates a new child object under \" + name, AddChild );\n\t}\n\n\tvoid Destroy()\n\t{\n\t\tDestroy( gameObject );\n\t}\n\n\tpublic static void CreateCubeAt( Vector3 position )\n\t{\n\t\tGameObject.CreatePrimitive( PrimitiveType.Cube ).transform.position = position;\n\t}\n\n\tprivate GameObject AddChild( string name )\n\t{\n\t\tGameObject child = new GameObject( name );\n\t\tchild.transform.SetParent( transform );\n\n\t\treturn child;\n\t}\n}\n```\n\n- **Static Functions (weakly typed)**\n\nUse `DebugLogConsole.AddCommandStatic( string command, string description, string methodName, System.Type ownerType )`. Here, **methodName** is the name of the method in string format, and **ownerType** is the type of the owner class. It may seem strange to provide the method name in string and/or provide the type of the class; however, after hours of research, I found it the best way to register any function with any number of parameters and parameter types into the system without knowing the signature of the method.\n\n```csharp\nusing UnityEngine;\nusing IngameDebugConsole;\n\npublic class TestScript : MonoBehaviour\n{\n\tvoid Start()\n\t{\n\t\tDebugLogConsole.AddCommandStatic( \"cube\", \"Creates a cube at specified position\", \"CreateCubeAt\", typeof( TestScript ) );\n\t}\n\t\n\tpublic static void CreateCubeAt( Vector3 position )\n\t{\n\t\tGameObject.CreatePrimitive( PrimitiveType.Cube ).transform.position = position;\n\t}\n}\n```\n\n- **Instance Functions (weakly typed)**\n\nUse `DebugLogConsole.AddCommandInstance( string command, string description, string methodName, object instance )`:\n\n```csharp\nusing UnityEngine;\nusing IngameDebugConsole;\n\npublic class TestScript : MonoBehaviour\n{\n\tvoid Start()\n\t{\n\t\tDebugLogConsole.AddCommandInstance( \"cube\", \"Creates a cube at specified position\", \"CreateCubeAt\", this );\n\t}\n\t\n\tvoid CreateCubeAt( Vector3 position )\n\t{\n\t\tGameObject.CreatePrimitive( PrimitiveType.Cube ).transform.position = position;\n\t}\n}\n```\n\nThe only difference with *AddCommandStatic* is that, you have to provide an actual instance of the class that owns the function, instead of the type of the class.\n\n### Removing Commands\n\nUse `DebugLogConsole.RemoveCommand( string command )` or one of the `DebugLogConsole.RemoveCommand( System.Action method )` variants.\n\n### Extending Supported Parameter Types\n\n- **Strongly Typed Functions**\n\nUse `DebugLogConsole.AddCustomParameterType( Type type, ParseFunction parseFunction, string typeReadableName = null )`:\n\n```csharp\nusing UnityEngine;\nusing IngameDebugConsole;\n\npublic class TestScript : MonoBehaviour\n{\n\tpublic class Person\n\t{\n\t\tpublic string Name;\n\t\tpublic int Age;\n\t}\n\n\tvoid Start()\n\t{\n\t\t// Person parameters can now be used in commands, e.g. ('John Doe' 18)\n\t\tDebugLogConsole.AddCustomParameterType( typeof( Person ), ParsePerson );\n\t}\n\t\n\tprivate static bool ParsePerson( string input, out object output )\n\t{\n\t\t// Split the input\n\t\t// This will turn ('John Doe' 18) into 2 strings: \"John Doe\" (without quotes) and \"18\" (without quotes)\n\t\tList\u003cstring\u003e inputSplit = new List\u003cstring\u003e( 2 );\n\t\tDebugLogConsole.FetchArgumentsFromCommand( input, inputSplit );\n\n\t\t// We need 2 parameters: Name and Age\n\t\tif( inputSplit.Count != 2 )\n\t\t{\n\t\t\toutput = null;\n\t\t\treturn false;\n\t\t}\n\n\t\t// Try parsing the age\n\t\tobject age;\n\t\tif( !DebugLogConsole.ParseInt( inputSplit[1], out age ) )\n\t\t{\n\t\t\toutput = null;\n\t\t\treturn false;\n\t\t}\n\n\t\t// Create the resulting object and assign it to output\n\t\toutput = new Person()\n\t\t{\n\t\t\tName = inputSplit[0],\n\t\t\tAge = (int) age\n\t\t};\n\n\t\t// Successfully parsed!\n\t\treturn true;\n\t}\n}\n```\n\n- **ConsoleCustomTypeParser Attribute**\n\nSimply add **IngameDebugConsole.ConsoleCustomTypeParser** attribute to your functions. These functions must have the following signature: `public static bool ParseFunction( string input, out object output );`\n\n```csharp\nusing UnityEngine;\nusing IngameDebugConsole;\n\npublic class TestScript : MonoBehaviour\n{\n\t[ConsoleCustomTypeParser( typeof( Person ) )]\n\tpublic static bool ParsePerson( string input, out object output )\n\t{\n\t\t// Same as above...\n\t}\n}\n```\n\n### Removing Supported Custom Parameter Types\n\nUse `DebugLogConsole.RemoveCustomParameterType( Type type )`.\n","funding_links":["https://github.com/sponsors/yasirkula","https://yasirkula.itch.io/unity3d/donate"],"categories":["C\\#","C#","Open Source Packages","UI Debug","C# #"],"sub_categories":["Console"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasirkula%2FUnityIngameDebugConsole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyasirkula%2FUnityIngameDebugConsole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasirkula%2FUnityIngameDebugConsole/lists"}