Skip to content

NetworkObject.GlobalObjectIdHash serializes invalid values when in Prefab Mode #2653

@Yoraiz0r

Description

@Yoraiz0r

Description

NetworkObject.GlobalObjectIdHash serializes to a non-unique invalid value if it is saved when the object that holds it is in Prefab Mode.

Specifically, the issue originates from var globalObjectIdString = UnityEditor.GlobalObjectId.GetGlobalObjectIdSlow(this).ToString();, in NetworkObject.GenerateGlobalObjectIdHash which will always return GlobalObjectId_V1-0-00000000000000000000000000000000-0-0 in prefab mode.

Once the object has a corrupt hash, it seems impossible to fix, and the prefab is doomed to stay corrupt without manual script tampering.

Reproduce Steps

  1. In the project view window, right click -> create -> 'Prefab'
  2. Double click the prefab to enter 'Prefab Mode' in which you can edit the newly made prefab
  3. Add a 'NetworkObject' component and witness its readonly GlobalObjectIdHash to be 951099334 which is the hash of GlobalObjectId_V1-0-00000000000000000000000000000000-0-0.
  4. Ctrl+S to save the prefab
  5. Inspect the newly made New Prefab.prefab file in any text editor of your choice, and witness that GlobalObjectIdHash: 951099334
  6. (bonus), exit prefab mode, and select New Prefab in the project view, witness that the GlobalObjectIdHash is a non-951099334 value, despite being serialized as such.

Actual Outcome

GlobalObjectIdHash is broken and non-unique, unusable.

Expected Outcome

GlobalObjectIdHash should always be unique traceable to a unique object between different clients.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment

  • OS: Windows 10
  • Unity Version: 2023.1.3f1
  • Netcode Version: 1.5.1

Metadata

Metadata

Labels

priority:highThis issue has high priority and we are focusing to resolve itstat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions