Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GlobalObjectIdHash collisions occur when a prefab has instances in multiple scenes before adding NetworkObject #2644

Closed
zachstronaut opened this issue Jul 26, 2023 · 2 comments · Fixed by #2707
Assignees
Labels
priority:high stat:imported Issue is tracked internally at Unity type:bug Bug Report

Comments

@zachstronaut
Copy link

zachstronaut commented Jul 26, 2023

Description

When a prefab exists in multiple scenes, and then later you add a NetworkObject that that prefab, the instances will have GlobalObjectIdHash collisions in any unopened scenes when you make this edit.

Reproduce Steps

  1. Open Bossroom sample
  2. Open DungeonEntrance scene
  3. Create a new prefab and add two instances to scene and save
  4. Open DungeonBossRoom scene
  5. Add two instances of the new prefab to scene and save
  6. Edit the prefab and add a NetworkObject
  7. Open Startup scene
  8. Run game and ready-up into gameplay
  9. Error will occur

Actual Outcome

"Exception: TestPrefab (1) tried to registered with ScenePlacedObjects which already contains the same GlobalObjectIdHash value 3700887716 for TestPrefab!"

Expected Outcome

Every instance of the prefab would have a unique id.

Netcode needs a way to handle NetworkObject GUIDs (GlobalObjectId) outside of OnValidate() because of issues like this. Netcode also doesn't provide any menu option to re-issue ids to every NetworkObject in a scene and we've had to build that ourselves.

Environment

  • OS: Windows 11
  • Unity Version: 2022.3.0, 2021.3.11
  • Netcode Version: 1.4.0, 1.5.1
@zachstronaut zachstronaut added stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report labels Jul 26, 2023
@zachstronaut zachstronaut changed the title Globalo GlobalObjectIdHash collisions occur when a prefab has instances in multiple scenes before adding NetworkObject Jul 26, 2023
@zachstronaut
Copy link
Author

Additionally, if you open the scenes after the fact and look at these new NetworkObjects in the Inspector they will visually show unique ids but the scene will not be dirty so it will not be save-able.

@fluong6 fluong6 added priority:high stat:import stat:imported Issue is tracked internally at Unity and removed stat:awaiting triage Status - Awaiting triage from the Netcode team. stat:import labels Jul 26, 2023
@NoelStephensUnity
Copy link
Collaborator

@zachstronaut
I believe #2662 resolves this issue.
Did a quick test using some of the test project scenes and it seemed to work fine.
(will run the exact same steps you outlined above using Boss Room in the morning to double check)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:high stat:imported Issue is tracked internally at Unity type:bug Bug Report
Projects
None yet
3 participants