Basically, I am working with the Unity VR multiplayer template, and I have scenes that go from 0 to a different scene back to 0 and disconnect the clients, not the host. scene 0 has a bunch of objects like the Network Manager VR Multiplayer and XRI connection Manger (these 2 are the ones with the guide issue) and others that need to persist across scenes but never duplicate when they are at scene 0 hence the script attached.
I replicate the important part here and want to note that this is awfully overcomplicated (also unclear who or what sets foundOriginal before that script’s Awake runs):
void Awake()
{
// Check for existing instances
if (!foundOriginal)
{
isOriginal = true;
DontDestroyOnLoad(gameObject);
foreach (GameObject obj in managedObjects)
{
if (obj != null)
{
// Remove SceneObjectGuid components
SceneObjectGuid[] guids = obj.GetComponentsInChildren<SceneObjectGuid>(true);
foreach (SceneObjectGuid guid in guids)
{
DestroyImmediate(guid);
}
DontDestroyOnLoad(obj);
}
}
}
}
Then simply add that script to each object that you want to be in DDOL. This provides the most flexibility AND most importantly, it’s calling out to you from the Inspector “hey look at me, I’m going to be in DDOL no question about it!”.
The removal of the guid scripts should be a separate MonoBehaviour too, and you also put that on every game object that needs to do this.
Prefer to make more but simpler components. That way you can make a lot of reusable building blocks rather than highly specialized code that’s also going to become more and more confusing.