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
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
Create a new Unity project, set up MLAPI, etc
In the Assets folder, right click then select "Create new" -> "Prefab"
Open the prefab by double clicking it
Add a "NetworkingManager" component to the prefab
Return to the scene view
Open the prefab again
Note that the open scene was added to the prefab
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):
OS: Windows 10
Unity Version: 2020.2.1f1
MLAPI Version: v12.1.7
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() {}
}
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.
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: