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.12k stars 430 forks source link

Prefabs with NetworkingManager component automatically add any open scene to list of networked scenes #589

Closed roglew closed 2 years ago

roglew commented 3 years ago

Describe the bug Prefabs with a NetworkingManager component automatically add any open scene to its list of networked scenes. This is because the NetworkingManager checks if the open scene is in its list of scene names in its OnValidate function. Prefabs will have their OnValidate function called regardless of if there is an instance of it in the scene.

To Reproduce

Expected behavior Prefabs with a NetworkingManager component should not automatically add open scenes to its list of registered scenes. Prefab instances placed in a scene may behave this way but the prefabs themselves should not.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context At the moment this can be worked around by making a sublcass of the NetworkingManager with an empty OnValidate function and using that instead. Obviously this prevents any other validations it would do as well:

using MLAPI;

public class NetworkingManagerNoValidate : NetworkingManager
{
    void OnValidate() {}
}
will-mearns commented 3 years ago

Adding to Bug backlog for triage - MTTSDK-22

NoelStephensUnity commented 2 years ago

Hi @roglew, This should no longer be an issue in Netcode for GameObjects v1.0.0-pre.x versions. Upgrade to the most recent version should resolve this issue for you.