{"id":48891647,"url":"https://github.com/niqibiao/unity-csharpconsole","last_synced_at":"2026-04-16T08:05:51.704Z","repository":{"id":349588593,"uuid":"1202425084","full_name":"niqibiao/unity-csharpconsole","owner":"niqibiao","description":"Interactive C# REPL for Unity Editor \u0026 Runtime powered by Roslyn. Top-level scripting, semantic code completion, cross-submission state, private member access, and remote IL2CPP execution via HybridCLR. UPM package.","archived":false,"fork":false,"pushed_at":"2026-04-15T11:10:21.000Z","size":6623,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-15T13:20:06.428Z","etag":null,"topics":["code-completion","console","csharp","il2cpp","interactive","repl","runtime-debugging","unity3d","upm"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niqibiao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-06T02:27:51.000Z","updated_at":"2026-04-15T11:10:22.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/niqibiao/unity-csharpconsole","commit_stats":null,"previous_names":["niqibiao/unity-csharpconsole"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/niqibiao/unity-csharpconsole","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niqibiao%2Funity-csharpconsole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niqibiao%2Funity-csharpconsole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niqibiao%2Funity-csharpconsole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niqibiao%2Funity-csharpconsole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niqibiao","download_url":"https://codeload.github.com/niqibiao/unity-csharpconsole/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niqibiao%2Funity-csharpconsole/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31876860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T07:36:03.521Z","status":"ssl_error","status_checked_at":"2026-04-16T07:35:53.576Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["code-completion","console","csharp","il2cpp","interactive","repl","runtime-debugging","unity3d","upm"],"created_at":"2026-04-16T08:05:13.922Z","updated_at":"2026-04-16T08:05:51.684Z","avatar_url":"https://github.com/niqibiao.png","language":"C#","funding_links":[],"categories":["Open Source Repositories"],"sub_categories":["Console"],"readme":"\u003cdiv align=\"center\"\u003e\n\n# CSharp Console\n\n**Interactive C# REPL for Unity — powered by Roslyn**\n\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)\n[![Unity](https://img.shields.io/badge/Unity-2022.3%2B-black.svg?logo=unity)](https://unity.com/)\n[![Claude Code](https://img.shields.io/badge/Claude_Code-blueviolet.svg?logo=anthropic)](https://claude.ai/code)\n[![UPM](https://img.shields.io/badge/UPM-Package-brightgreen.svg)](package.json)\n\nExecute C# code on the fly in Unity Editor \u0026 Runtime — no compilation wait, no boilerplate,\u003cbr/\u003e\nfull access to your project's live state. **Editor zero-config, Runtime just works with HybridCLR.**\n\n[Features](#features) · [Installation](#installation) · [Quick Start](#quick-start) · [REPL Usage](#repl-usage) · [Extending Commands](#extending-commands)\n\nEnglish | [中文](README_zh.md)\n\n\u003c/div\u003e\n\n---\n\n## ✦ Features\n\n### Core Capabilities\n\n| | Feature | Description |\n|:--:|---------|-------------|\n| **\u003e\\_** | **Interactive REPL** | Roslyn-based script submissions with persistent session state — variables, `using` directives, and types survive across executions |\n| **#** | **Top-level Syntax** | Write statements directly. No `class`, no `Main`, no boilerplate |\n| **@** | **Command Framework** | Extensible `[CommandAction]` commands with automatic JSON-to-parameter binding (positional \u0026 named args), `/batch` endpoint for multi-command workflows |\n| **Tab** | **Semantic Completion** | Real-time member, namespace, and type completions directly from Roslyn |\n| **🔓** | **Private Member Access** | Bypass `private` / `protected` / `internal` access modifiers at compile time for deep inspection |\n| **📡** | **Remote Execution** | Compile in the Editor, execute on a connected Player build (IL2CPP via HybridCLR) |\n\n### How It Looks\n\n\u003cimg src=\"Docs~/images/repl-0.gif\" width=\"100%\" /\u003e\n\n#### Immediate evaluation — no class, no Main, just code\n\n```csharp\nDateTime.Now.ToString(\"yyyy-MM-dd HH:mm:ss\")\n```\n\n\u003cimg src=\"Docs~/images/repl-1.png\" /\u003e\n\n#### Cross-submission state — variables survive across submissions\n\n```csharp\nvar cam = Camera.main; cam.transform.position\n```\n\n\u003cimg src=\"Docs~/images/repl-2.png\" /\u003e\n\n#### Private member access — bypass access modifiers at compile time\n\n```csharp\nvar go = GameObject.Find(\"Main Camera\");\ngo.m_InstanceID\n```\n\n\u003cimg src=\"Docs~/images/repl-3.png\" /\u003e\n\n#### LINQ over live scene objects\n\n```csharp\nstring.Join(\", \", UnityEngine.Object.FindObjectsOfType\u003cRigidbody\u003e().Select(x =\u003e x.name))\n```\n\n\u003cimg src=\"Docs~/images/repl-4.png\" /\u003e\n\n#### Command expressions — invoke server-side commands directly\n\n```csharp\n@editor.status()\n```\n\n\u003cimg src=\"Docs~/images/repl-5.png\" /\u003e\n\n## ⚙ Installation\n\nAdd via `Packages/manifest.json`:\n\n```json\n{\n  \"dependencies\": {\n    \"com.zh1zh1.csharpconsole\": \"https://github.com/niqibiao/unity-csharpconsole.git\"\n  }\n}\n```\n\nOr reference as a local package:\n\n```json\n{\n  \"dependencies\": {\n    \"com.zh1zh1.csharpconsole\": \"file:../com.zh1zh1.csharpconsole\"\n  }\n}\n```\n\n\u003e **Note:** Both assembly definitions have `autoReferenced: false`. If your code needs to reference this package, add `Zh1Zh1.CSharpConsole.Runtime` (or `.Editor`) to your asmdef's references explicitly.\n\n## ▶ Quick Start\n\n### Editor — Zero Configuration\n\n**Import the package and it just works.** The Editor-side HTTP service starts automatically via `[InitializeOnLoadMethod]` — no initialization code, no settings to tweak, no manual setup. Open the REPL from the Unity menu:\n\n| Menu Item | Target |\n|-----------|--------|\n| **Console \u003e C#Console** | Local Editor |\n| **Console \u003e RemoteC#Console** | Remote Editor / Player |\n\n### Runtime — One Line, No Extra Setup\n\nEnable the remote console on a Player build with a single call:\n\n```csharp\n#if DEVELOPMENT_BUILD\nZh1Zh1.CSharpConsole.RuntimeInitializer.ConsoleInitialize();\n#endif\n```\n\nRuntime execution only depends on **HybridCLR**'s `Assembly.Load` capability for IL2CPP (no additional configuration needed).\n\n\u003e The runtime assembly is gated by `DEVELOPMENT_BUILD || UNITY_EDITOR`.\n\n| | Port |\n|--|------|\n| Editor | `14500` (default) |\n| Runtime | `15500` (default) |\n\nIf a port is occupied, the service automatically advances to the next available one.\n\n## ⌨ REPL Usage\n\n### Starting the REPL\n\nThe recommended way is through the Unity menu. You can also launch directly:\n\n```bash\n# Auto-discover running Unity Editors\npython \"Editor/ExternalTool~/console-client/csharp_repl.py\"\n\n# Connect to a specific Editor\npython \"Editor/ExternalTool~/console-client/csharp_repl.py\" --editor --ip 127.0.0.1 --port 14500\n\n# Connect to a Runtime Player (with Editor as compile server)\npython \"Editor/ExternalTool~/console-client/csharp_repl.py\" \\\n  --mode runtime --ip 127.0.0.1 --port 15500 \\\n  --compile-ip 127.0.0.1 --compile-port 14500\n```\n\nPython 3.7+ is required. Python dependencies (`requests`, `prompt_toolkit`, `Pygments`) are installed automatically on first launch.\n\n### Remote Runtime — Optional Settings\n\nWhen connecting to a Runtime Player via **Console \u003e RemoteC#Console**, two optional settings are available to improve compilation accuracy:\n\n| Setting | Description |\n|---------|-------------|\n| **Runtime Dll Path** | Directory containing the player's compiled assemblies. The compiler uses these DLLs instead of Editor assemblies to resolve types, ensuring the compiled code matches what the player actually has. Recommended path: `Library/Bee/PlayerScriptAssemblies` (populated after a player build). |\n| **Runtime Defines File** | A `.txt` file listing preprocessor defines that match the player's build configuration, ensuring `#if` directives evaluate the same way as in the player. Supports one define per line or semicolon-separated (e.g. `UNITY_ANDROID;IL2CPP;DEVELOPMENT_BUILD`). |\n\nBoth settings are persisted in `EditorPrefs` and only apply when **Remote Is Editor** is unchecked. Leave them empty to use defaults (Editor assemblies and defines).\n\n### Key Bindings\n\n| Key | Action |\n|-----|--------|\n| `Enter` | Submit input |\n| `Ctrl+Enter` | Insert newline without submitting |\n| `Tab` | Accept completion candidate |\n| `Ctrl+R` | Reverse history search |\n| `Ctrl+C` | Clear input (confirm quit if empty) |\n\nCompletion activates automatically as you type. The toolbar shows semantic completion status: on `●` / off `○`.\n\n### Built-in Commands\n\n| Command | Description |\n|---------|-------------|\n| `/completion \u003c0\\|1\u003e` | Toggle semantic completion |\n| `/using` | Show default `using` file path |\n| `/define` | Show preprocessor defines file path |\n| `/reload` | Reload `using` / `define` files |\n| `/reset` | Reset the REPL session |\n| `/clear` | Clear the terminal |\n| `/dofile \u003cpath\u003e` | Execute a local `.cs` file |\n\n### Command Expressions\n\nThe REPL supports `@`-prefixed command expressions that invoke the server-side command framework directly — bypassing Roslyn compilation:\n\n```text\n@project.scene.open(scenePath: \"Assets/Scenes/SampleScene.unity\", mode: \"single\")\n@editor.status()\n@session.inspect(sessionId: \"session-1\")\n```\n\nTab completion works for both command names and argument names.\n\n## 📋 Built-in Actions\n\n50 built-in commands across 13 namespaces, covering editor control, scene manipulation, asset management, and more.\n\n| Namespace | Action | Description |\n|-----------|--------|-------------|\n| **gameobject** | `find` | Find GameObjects by name, tag, or component type |\n| | `create` | Create a new GameObject (empty or primitive) |\n| | `destroy` | Destroy a GameObject |\n| | `get` | Get detailed info about a GameObject |\n| | `modify` | Change name, tag, layer, active state, or static flag |\n| | `set_parent` | Reparent a GameObject |\n| | `duplicate` | Duplicate a GameObject |\n| **component** | `add` | Add a component to a GameObject |\n| | `remove` | Remove a component from a GameObject |\n| | `get` | Get serialized field data of a component |\n| | `modify` | Modify serialized fields of a component |\n| **transform** | `get` | Get position, rotation, and scale |\n| | `set` | Set position, rotation, and/or scale (local or world) |\n| **scene** | `hierarchy` | Get the full scene hierarchy tree, optionally with component info |\n| **prefab** | `create` | Create a prefab asset from a scene GameObject |\n| | `instantiate` | Instantiate a prefab into the active scene |\n| | `unpack` | Unpack a prefab instance |\n| **material** | `create` | Create a new material asset with a specified shader |\n| | `get` | Get material properties from an asset or a Renderer |\n| | `assign` | Assign a material to a Renderer component |\n| **screenshot** | `scene_view` | Capture the Scene View to an image file |\n| | `game_view` | Capture the Game View to an image file |\n| **profiler** | `start` | Start Profiler recording (optional deep profiling) |\n| | `stop` | Stop Profiler recording |\n| | `status` | Get current Profiler state |\n| | `save` | Save recorded profiler data to a `.raw` file |\n| **editor** | `status` | Get editor state and play mode info |\n| | `playmode.status` | Get current play mode state |\n| | `playmode.enter` | Enter play mode |\n| | `playmode.exit` | Exit play mode |\n| | `menu.open` | Execute a menu item by path |\n| | `window.open` | Open an editor window by type name |\n| | `console.clear` | Clear the editor console |\n| | `console.mark` | Write a searchable marker into the editor log and return the log file path |\n| **project** | `scene.list` | List all scenes in the project |\n| | `scene.open` | Open a scene by path |\n| | `scene.save` | Save the current scene |\n| | `selection.get` | Get the current editor selection |\n| | `selection.set` | Set the editor selection |\n| | `asset.list` | List assets by type filter |\n| | `asset.import` | Import an asset by path |\n| | `asset.reimport` | Reimport an asset by path |\n| **asset** | `move` | Move or rename an asset |\n| | `copy` | Copy an asset to a new path |\n| | `delete` | Delete one or more assets |\n| | `create_folder` | Create a folder in the Asset Database |\n| **session** | `list` | List active REPL sessions |\n| | `inspect` | Inspect a session's state |\n| | `reset` | Reset a session's compiler and executor |\n| **command** | `list` | List all registered commands (built-in + custom) |\n\n\u003e Most actions are editor-only. `session.*` and `command.list` are available on Runtime builds as well.\n\n## 🔌 Extending Commands\n\nThe command framework lets any project add custom commands without modifying the package source — declare a `[CommandAction]` method and the framework handles discovery, parameter binding, and routing automatically.\n\nSee the full guide: **[Extending Commands](Docs~/ExtendingCommands.md)**\n\n## 📦 Requirements\n\n| Dependency | Version |\n|------------|---------|\n| Unity | 2022.3+ (theoretically 2019+ compatible, but untested) |\n| Python | 3.7+ (on system `PATH`) |\n| Windows Terminal | Optional (falls back to Python directly) |\n\n## 🔗 Related Projects\n\n- **[unity-cli-plugin](https://github.com/niqibiao/unity-cli-plugin)** — Non-interactive CLI for the same HTTP service, designed for scripting and automation workflows.\n- **[python-prompt-toolkit](https://github.com/prompt-toolkit/python-prompt-toolkit)** — Terminal UI library powering the REPL's interactive interface.\n- **[HybridCLR](https://github.com/focus-creative-games/hybridclr)** — IL2CPP hot-reload solution enabling `Assembly.Load` in Runtime mode.\n\n## 📄 Third-Party Notices\n\nThis package bundles Roslyn compiler assemblies and dnlib under `Editor/Plugins/`. See [ThirdPartyNotices.md](ThirdPartyNotices.md) for full attribution and license details.\n\n## 📜 License\n\n[Apache License 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniqibiao%2Funity-csharpconsole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniqibiao%2Funity-csharpconsole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniqibiao%2Funity-csharpconsole/lists"}