Skip to content

feat: CLI NetworkVariable values, in-scene id audit and id-on-save fix - #4258

Draft
jy-vivox wants to merge 2 commits into
develop-3.x.xfrom
feat/mtt-16737-hackday-netcode-frictions
Draft

jy-vivox wants to merge 2 commits into
develop-3.x.xfrom
feat/mtt-16737-hackday-netcode-frictions

Conversation

@jy-vivox

@jy-vivox jy-vivox commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Purpose of this PR

Fixes NGO frictions found in the hack-day agent runs, so agents don't need script eval or workarounds that the build-multiplayer-game skill has to explain.

  • get_object returns NetworkVariable values. Agents read game state (phase, score, timers) by writing script eval code. get_object now returns each NetworkBehaviour's NetworkVariable and NetworkList values as the peer sees them: enums as names, vectors, quaternions and colours as arrays, structs as their fields, fixed strings as text, object and behaviour references as ids, and collections capped at 32 items with the full count. A variable the client can't read says why instead of failing the call. Nested behaviours carry their child path. --behaviour filters to one type and --variables false gives the previous short form.
  • In-scene NetworkObjects saved with id 0. In one hack-day game, the match never started because a NetworkObject was added to a scene built by script eval before the scene's first save. OnValidate doesn't assign GlobalObjectIdHash until the scene has a path, and the later revalidation doesn't mark the scene dirty, so the save kept 0. A sceneSaved hook now assigns missing ids in the saved scene and saves again, with a re-entrancy guard, and does nothing in play mode.
  • audit checks scenes. It reports IN_SCENE_ID_MISSING for in-scene NetworkObjects with id 0, and SCENE_NOT_SAVED for NetworkObjects in a scene that has never been saved. --scope scenes runs only these checks.

Trade-off: reading values uses reflection on the Value property and on GetEnumerator. NetworkList<T> has a public GetEnumerator but doesn't implement IEnumerable. This runs only when the CLI asks for one object.

Jira ticket

MTT-16737 (sub-task of MTT-16728)

Changelog

com.unity.netcode.gameobjects

  • Added: netcode.gameobjects get_object returns each NetworkBehaviour's NetworkVariable and NetworkList values as the peer sees them, and the child path of nested behaviours. --behaviour limits the values to one behaviour type, and --variables false gives the previous short form.
  • Added: netcode.gameobjects audit checks in-scene NetworkObjects for a missing network id (GlobalObjectIdHash 0), and takes --scope scenes to run only that check.
  • Fixed: Issue where a NetworkObject added to a scene before the scene was first saved, for example by an editor script, was saved with a GlobalObjectIdHash of 0 and never spawned. Saving the scene now assigns the missing id and saves it again.

Documentation

  • Includes edits to existing public API documentation: the get_object and audit rows of Documentation~/unity-cli-commands.md.

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

Functional Testing

Manual testing :

  • Manual testing done

These checks ran in a live 6000.7.0b10 Editor driven through the unity CLI, with Unity Netcode 7.2.0.

  • Save fix. A scene was built with script eval, adding a NetworkObject before the first save. The id was 0 before the save and non-zero after, both in memory and in the .unity file, and the scene wasn't left dirty.
  • Audit, clean and unsaved. audit --scope scenes is clean for that scene and warns SCENE_NOT_SAVED for an unsaved scene.
  • Audit, forced 0. After forcing the id to 0, the audit reports IN_SCENE_ID_MISSING with the object's name, and the next save writes the id back.
  • Values on a host. With a host running, get_object returned correct values for an enum, a struct, a FixedString64Bytes, a Vector3, an owner-read int, and a 40-item NetworkList (32 shown, count: 40, truncated: true). The --behaviour and --variables false options behave as described.

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests: FormatValue_TurnsValuesIntoPlainData, RunningHost_GetObjectReturnsNetworkVariableValues, InSceneNetworkObject_GetsItsIdOnSave_AndAuditReportsMissingIds, and the updated wire table in NetcodeGameObjectsCliCommandsTests.

On 6000.7.0b10 the full NGO edit-mode suite passed: 1444 passed, 1 skipped, 0 failed.

Does the change require QA team to:

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

Up-port

Not needed. The CLI commands exist only in 3.x, and this targets develop-3.x.x.

Backports

Not needed: the CLI commands are specific to NGO 3.x.


Companion PRs under MTT-16728: Unity Netcode netcode.ghost set (MTT-16738) https://github.cds.internal.unity3d.com/unity/unity/pull/141076 and the build-multiplayer-game skill (MTT-16729) https://github.cds.internal.unity3d.com/unity/skills/pull/293.

🤖 Generated with Claude Code

jy-vivox and others added 2 commits November 25, 2026 15:17
MTT-16737)

- get_object returns each NetworkBehaviour's NetworkVariable and NetworkList
  values as the peer sees them, with nested behaviours' child paths.
  --behaviour filters to one type; --variables false gives the short form.
- audit checks in-scene NetworkObjects for GlobalObjectIdHash 0 and takes
  --scope scenes.
- Saving a scene assigns ids that NetworkObjects added before the scene's
  first save are missing, and saves again, so they spawn.

Found in the hack-day agent runs: agents read NetworkVariables with
script eval, and one game's match never started because its in-scene
NetworkObject was saved with id 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jy-vivox
jy-vivox force-pushed the feat/mtt-16737-hackday-netcode-frictions branch from 063b5af to 572b741 Compare November 25, 2026 21:45

This branch has not been deployed

No deployments
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