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
- In the project view window, right click -> create -> 'Prefab'
- Double click the prefab to enter 'Prefab Mode' in which you can edit the newly made prefab
- Add a 'NetworkObject' component and witness its readonly GlobalObjectIdHash to be
951099334 which is the hash of GlobalObjectId_V1-0-00000000000000000000000000000000-0-0.
- Ctrl+S to save the prefab
- Inspect the newly made
New Prefab.prefab file in any text editor of your choice, and witness that GlobalObjectIdHash: 951099334
- (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
Description
NetworkObject.GlobalObjectIdHashserializes 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();, inNetworkObject.GenerateGlobalObjectIdHashwhich will always returnGlobalObjectId_V1-0-00000000000000000000000000000000-0-0in 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
951099334which is the hash ofGlobalObjectId_V1-0-00000000000000000000000000000000-0-0.New Prefab.prefabfile in any text editor of your choice, and witness thatGlobalObjectIdHash: 951099334New Prefabin the project view, witness that theGlobalObjectIdHashis 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