/// <summary> /// Runs only on the Server, just so signal that a remote client has loaded scene /// </summary> public override void OnEvent(LoadSceneResponse evnt) { if (BoltNetwork.IsServer) { if (evnt.Load) { BoltLog.Warn("Connection {0} has loaded scene {1}", evnt.RaisedBy, evnt.SceneName); } else { BoltLog.Warn("Connection {0} has unloaded scene {1}", evnt.RaisedBy, evnt.SceneName); } } }
/// <summary> /// Runs only the client side. /// The Server requests that a certain scene to be loaded, and the client replies with Response /// confirming the scene load. /// </summary> public override void OnEvent(LoadSceneRequest evnt) { if (BoltNetwork.IsClient) { if (evnt.Load) { if (loadedScenes.Contains(evnt.SceneName) == false) { SceneManager.LoadSceneAsync(evnt.SceneName, LoadSceneMode.Additive); loadedScenes.Add(evnt.SceneName); } } else { SceneManager.UnloadSceneAsync(evnt.SceneName); loadedScenes.Remove(evnt.SceneName); } var evt = LoadSceneResponse.Create(Bolt.GlobalTargets.OnlyServer); evt.SceneName = evnt.SceneName; evt.Load = evnt.Load; evt.Send(); } }