Unity C# Navigate
Navigate and search C# source via unity-cli local tools. This is the read-only sibling of unity-csharp-edit; hand off as soon as the request implies a write.
Use When
- The user wants to inspect a script or understand existing C# behavior.
- The user asks where a symbol is defined or referenced.
- The user wants to search packages or source trees before making a change.
Do Not Use When
- The user wants to modify code or create new C# files; use
unity-csharp-edit. - The task depends on Unity scene state rather than source; use
unity-scene-inspect.
Preferred Flow
- Build or refresh the index before symbol-heavy queries.
- Anchor on the right file with
readorsearch. - Use
get_symbols,find_symbol, andfind_refsonce the target identifier is clear. - Narrow the search path or page size if the result set is large.
- Use
list_packageswhen the question might involve packages rather than project sources.
unity-cli raw read --json '{"path":"Assets/Scripts/Player.cs"}'
unity-cli raw search --json '{"pattern":"OnCollisionEnter","path":"Assets/Scripts"}'
unity-cli raw find_symbol --json '{"name":"PlayerController","kind":"class","scope":"assets"}'
unity-cli raw find_refs --json '{"name":"Health","scope":"assets","pageSize":20}'
Examples
- "Read
PlayerController.csand explain how jumping works." - "Find every reference to
Healthin project scripts." - "List installed packages and check whether Input System is present."
References
- runtime-checklist.md: connection and instance prerequisites.
- code-search-playbook.md: indexing strategy, path narrowing, and reference tracing guidance.