Unity 2021.3
Netcode 1.9.1
Not sure what that script is doing exactly, but when playing the game inside the editor, I get huge spikes that drop the frame rate very low every second.
I have a very large scene with tons of objects, but I managed to optimize my script enough to make it work very well with a large scene at 120 fps, but for some reason one random Netcode editor script keep lagging and I don’t know what it is or how to disable it. There are no message or warning in the console.
Fortunately since its an editor script, I have no issue in the build, it’s just that it would be great to be able to work from the editor directly. Any idea what this is? What is causing this?
Thank you.
Oh wow! That’s gruesome:
/// <summary>
/// Invoked only when the hierarchy changes
/// </summary>
private static void EditorApplication_hierarchyChanged()
{
var allNetworkManagers = Resources.FindObjectsOfTypeAll<NetworkManager>();
foreach (var networkManager in allNetworkManagers)
{
if (!networkManager.NetworkManagerCheckForParent())
{
Singleton.CheckAndNotifyUserNetworkObjectRemoved(networkManager);
}
}
}
This exists ONLY to tell a user that the NetworkManager must be at the root. Which it really needn’t be IMO!
You can safely edit the script and comment out the method or remove the event handler entirely.
Since you’re on 2021 you may have to copy the Netcode package under Assets. In Unity 6 at least I can now edit package scripts without them getting reverted right away, except when updating the package. Not sure if that’s a Unity 6 only feature, or whether that’s a feature at all and my editor is just fortunately broken in this way.
1 Like