Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.13k stars 433 forks source link

Not Working: "Refresh In-Scene Prefab Instances" #3067

Open zachstronaut opened 2 weeks ago

zachstronaut commented 2 weeks ago

Using the "Refresh In-Scene Prefab Instances" contextual menu on a prefab doesn't actually make any changes to the scenes that use the prefab. I have to manually go into the scenes in question and toggle the prefab gameobjects on/off in order to get Unity to recognize the new network guids as a dirty state that can be saved.

NoelStephensUnity commented 2 weeks ago

Hi @zachstronaut, What version of NGO are you using? Also, are the prefabs in-scene placed or are they dynamically spawned and included in a Network Prefab List?

zachstronaut commented 2 weeks ago

NGO 1.9.1 and these are in-scene placed prefabs that had a NetworkObject added to them so they needed to be updated in the scenes that used them so that unique network guids would get generated. Unity 2022.3.10f1, btw.

If you are not able to easily repro the problem (problem being: using the context menu from the prefab, seeing the popup load through the scenes, but then not actually have any changed files afterwards) -- like if this requires something else going on to reproduce -- then my one theory for you is that this prefab went from not networked at all to having a new NetworkObject at the top level AND adding a new nested child prefab that was already networked and already had a NetworkObject.

NoelStephensUnity commented 5 days ago

then my one theory for you is that this prefab went from not networked at all to having a new NetworkObject at the top level AND adding a new nested child prefab that was already networked and already had a NetworkObject.

That is very helpful...just getting back from a short break (needed some rest... 😹 ) and will be looking into this sometime tomorrow.

zachstronaut commented 4 days ago

Welcome back!

NoelStephensUnity commented 3 days ago

@zachstronaut Ok, I have replicated the issue and will work on getting a PR up by Monday. I am also going to provide logging of the results when using this tool so you can verify the NetworkObjects you would expect to be updated are updated. Just need to narrow down why the OnValidate is not recognizing the updated component on the root/parent when you add a NetworkObject to it.

Now that I have the steps to replicate it should be relatively easy to figure out.

NoelStephensUnity commented 3 days ago

@zachstronaut Update your project's manifest to use this:

"com.unity.netcode.gameobjects":"https://github.com/Unity-Technologies/com.unity.netcode.gameobjects.git?path=com.unity.netcode.gameobjects#fix/in-sceneobject-networkobject-update-in-editor-tool",

Let me know if this provides better results on your end too (to verify the issue I replicated on my end is indeed the same issue you are experiencing).

If it works for you, then I will open a PR for this update. 👍

zachstronaut commented 8 hours ago

This fix works as far as I can tell! Thanks, Noel!