Description
When using automatic scene management, SceneName is inconsistently reported in NetworkSceneManager.OnSceneEvent.
Reproduce Steps
- Enable automatic scene management
- Subscribe to
NetworkSceneManager.OnSceneEvent in networkManager.OnClientStarted
- Load a scene via
NetworkSceneManager by passing in a full scene path (e.g., Assets/Scenes/GameScene_02.unity)
- Track
SceneEvent.SceneName and SceneEvent.Scene arguments in OnSceneEvent callback
Actual Outcome
SceneEvent.SceneName in some event types contains the full scene path, in some only the scene name.
Expected Outcome
SceneEvent.SceneName should always be consistent - contain the full scene path or the scene name all the time.
Environment
- OS: Windows 10
- Unity Version:
6000.0.47f1
com.unity.netcode.gameobjects version: 2.3.2
com.unity.services.multiplayer version: 1.1.2
- Distributed authority, using sessions
Additional Context
I'm using distributed authority:
var multiplayerService = MultiplayerService.Instance;
var options = new SessionOptions
{
Name = multiplayerSessionNameId,
MaxPlayers = 10,
IsPrivate = false,
IsLocked = false,
}.WithDistributedAuthorityNetwork();
await multiplayerService.CreateOrJoinSessionAsync(multiplayerSessionNameId, options);
Loading the scene as follows:
var scenePath = SceneUtility.GetScenePathByBuildIndex(index);
Debug.Log($"Starting to load scenePath={scenePath}");
sceneManager.LoadScene(scenePath, LoadSceneMode.Additive);
Tracking the OnSceneEvent the following way:
private void OnSceneEvent(SceneEvent sceneEvent)
{
var sceneName = sceneEvent.SceneName;
var eventType = sceneEvent.SceneEventType;
var scene = sceneEvent.Scene;
Debug.Log($"{eventType}: sceneName={sceneName}, scene.name={scene.name}, scene.path={scene.path}");
}
Log lines that get printed:
Starting to load scenePath=Assets/Scenes/GameScene_02.unity
Load: sceneName=Assets/Scenes/GameScene_02.unity, scene.name=, scene.path=
LoadComplete: sceneName=GameScene_02, scene.name=GameScene_02, scene.path=Assets/Scenes/GameScene_02.unity
LoadEventCompleted: sceneName=GameScene_02, scene.name=, scene.path=
Description
When using automatic scene management,
SceneNameis inconsistently reported inNetworkSceneManager.OnSceneEvent.Reproduce Steps
NetworkSceneManager.OnSceneEventinnetworkManager.OnClientStartedNetworkSceneManagerby passing in a full scene path (e.g.,Assets/Scenes/GameScene_02.unity)SceneEvent.SceneNameandSceneEvent.Scenearguments inOnSceneEventcallbackActual Outcome
SceneEvent.SceneNamein some event types contains the full scene path, in some only the scene name.Expected Outcome
SceneEvent.SceneNameshould always be consistent - contain the full scene path or the scene name all the time.Environment
6000.0.47f1com.unity.netcode.gameobjectsversion:2.3.2com.unity.services.multiplayerversion:1.1.2Additional Context
I'm using distributed authority:
Loading the scene as follows:
Tracking the
OnSceneEventthe following way:Log lines that get printed: