Skip to content

feat: add Unity CLI commands for Netcode for GameObjects (MTT-16534) - #4206

Closed
jy-vivox wants to merge 6 commits into
develop-3.x.xfrom
feat/cli-commands-mtt-15298
Closed

jy-vivox wants to merge 6 commits into
develop-3.x.xfrom
feat/cli-commands-mtt-15298

Conversation

@jy-vivox

@jy-vivox jy-vivox commented Oct 21, 2026 •

Copy link
Copy Markdown

Purpose of this PR

Adds Unity CLI commands for Netcode for GameObjects, so agents and scripts can set up and drive an NGO
project through com.unity.pipeline (unity command <group> <name>).

25 commands, in netcode.gameobjects and its subgroups:

  • netcode.gameobjects: create a NetworkManager, make and register network prefabs, list prefabs,
    clients and spawned objects, get the network role, spawn, despawn and change ownership, and audit
    the project's network prefab setup.
  • netcode.gameobjects.session: start and stop a host, server or client.
  • netcode.gameobjects.config: read and set NetworkManager and transport settings, including the log level.
  • netcode.gameobjects.simulator: network simulator settings, presets, lag spikes and timeouts.
  • netcode.gameobjects.profiler: sample network traffic: bytes and messages sent and received, per message type.

The commands are in a separate editor assembly, Editor/CLI, that only compiles when
com.unity.pipeline 0.9.0-exp.1 or later is installed. NGO doesn't depend on the pipeline. The commands'
logic is in Editor/CliQueries, inside the existing editor assembly, so it is compiled and tested either way.

Simulator presets use Multiplayer Tools when it is installed: an optional reference with
a versionDefines entry (2.0.0 or later). Without it, the simulator commands use the transport's own
simulator settings.

Names follow the Netcode for Entities commands (netcode root), so both packages share one group root
and the same argument names.

Jira ticket

MTT-16534

Changelog

com.unity.netcode.gameobjects

  • Added: Unity CLI commands (netcode.gameobjects groups) to set up NetworkManagers and network prefabs, start and stop sessions, inspect clients and spawned objects, spawn, despawn and change ownership, simulate network conditions and sample network traffic. They are available when the project has com.unity.pipeline 0.9.0-exp.1 or later.

Documentation

  • Adds unity-cli-commands.md, with every command and its arguments, linked from the table of contents
    and from the testing and debugging page.

Testing & QA (How your changes can be verified during release Playtest)

Editor 6000.7.0b1, minimalproject:

  • 46/46 pass with the pipeline installed, with or without Multiplayer Tools. Without the pipeline, 39/39 pass,
    and the command assembly is correctly skipped.
  • All 25 commands run live with two Editors, a host and a remote client (a copy of the project):
    • authoring: create_network_manager, make_prefab, register_prefab, list_prefabs, audit, config;
    • session: connect, wait_ready on both sides, list_clients;
    • objects: spawn (server-owned, client-owned, player object), change_owner, despawn, list_objects
      and get_object on both peers, and the client-side refusals;
    • kick, then reconnect; stop, change config, start again as a server;
    • profiler get_stats with traffic: the client recorded each spawn, ownership change and despawn message.
  • Simulator turned on in edit mode, before the client started: RTT went from 11 ms to 315 ms with a 150 ms
    delay. A lag spike, then a timeout that drops the client after the 30 s disconnect timeout, reconnect
    afterwards, and turning it off restores the RTT.
  • With Multiplayer Tools 2.2.11: presets listed and applied (RTT 71 ms), lag spike, timeout.

Live testing found three issues, fixed here:

  • get_stats read the profiler's Network counters, which stayed at zero. It now reads NGO's message hooks.
  • reconnect refused a client that had been kicked or timed out.
  • An error message left an unsaved scene's name blank.

Functional Testing

Manual testing :

  • Manual testing done

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

If any boxes above are checked the QA team will be automatically added as a PR reviewer.

Up-port

Not needed: this targets develop-3.x.x.

Backports

None. The commands need the pipeline's command API from 0.9.0-exp.1.

Commands in the netcode.gameobjects groups for com.unity.pipeline 0.9.0 or later: set up
NetworkManagers and network prefabs, audit the project, start and stop sessions, inspect
clients and spawned objects, spawn, despawn and change ownership, simulate network
conditions and sample network traffic. The command assembly only compiles when the
pipeline package is installed; the logic lives in the editor assembly and is tested
without it.
A prerelease sorts below its release, so the 0.9.0 gate left the commands out of projects
with the published 0.9.0-exp.1.
Restore each transport's own simulator settings once the CLI simulator, timeout and lag spike
are off, and keep a timeout on through a lag spike. Gate the simulator presets on Multiplayer
Tools 2.0. Prefer an exact NetworkManager name, keep the transport protocol and WebSocket path
when setting the address, refuse address changes on Relay, and listen on every interface for a
remote address. Let the server own objects in client-server.
u-pr[bot]

This comment was marked as resolved.

- register_prefab treats a prefab as registered when a list entry overrides it,
  matching entries by source prefab or prefab id hash as NGO does at runtime.
- audit reports override entries with no target, a target without a root
  NetworkObject, or a hash override with a zero source hash.
- audit, list_prefabs and register_prefab handle empty list entries; audit
  reports them as a LIST_ENTRY_INVALID warning.
- make_prefab refuses prefabs with child NetworkObjects instead of saving an
  unsupported network prefab.
- config set refuses spawn_timeout outside 10-3600 seconds, and NaN or infinite
  float values.
- profiler get_stats reads traffic from the message manager's hooks, as NGO's own
  metrics do: bytes and messages sent and received, per message type. The
  profiler's Network counters it read before stayed at zero in a live session.
- session reconnect connects a client again after it was kicked or timed out,
  instead of refusing because it had already shut down.
- Messages name an unsaved scene as such instead of leaving the name blank.
@jy-vivox

Copy link
Copy Markdown
Author

/review

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Harness Review

Needs changes

The command layer is well separated from its query logic, but the new audit does not fully match runtime prefab registration rules.

Reviewed commit 4b0545d

🤖 Helpful? 👍/👎

Comment thread com.unity.netcode.gameobjects/Editor/CliQueries/NgoCliQueries.Authoring.cs Outdated
@jy-vivox jy-vivox changed the title feat: add Unity CLI commands for Netcode for GameObjects (MTT-15298) feat: add Unity CLI commands for Netcode for GameObjects (MTT-16534) Oct 22, 2026
@jy-vivox
jy-vivox force-pushed the feat/cli-commands-mtt-15298 branch from 2d993d1 to 561afc4 Compare October 22, 2026 17:57
@jy-vivox

Copy link
Copy Markdown
Author

Superseded by #4210 (same commits; branch renamed to the parent ticket MTT-15537). Closing without merging.

@jy-vivox jy-vivox closed this Oct 22, 2026
@jy-vivox
jy-vivox deleted the feat/cli-commands-mtt-15298 branch October 22, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant