Skip to content

Commit

Permalink
feat: adding a function for server to tell clients to load scene
Browse files Browse the repository at this point in the history
function should be called on server to load scene on client but not on server
  • Loading branch information
James-Frowen committed Feb 10, 2023
1 parent da956fc commit 14283b1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Assets/Mirage/Runtime/NetworkSceneManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,25 @@ private void RegisterServerMessages()
Server.MessageHandler.RegisterHandler<SceneReadyMessage>(HandlePlayerSceneReady);
}

/// <summary>
/// Loads a scene on players but NOT on server
/// <para>Note: does not load for Host player, they should be loaded using server methods instead</para>
/// </summary>
/// <param name="scenePath"></param>
/// <param name="players"></param>
/// <param name="shouldClientLoadOrUnloadNormally"></param>
/// <param name="sceneOperation"></param>
/// <param name="loadSceneParameters"></param>
public void ServerLoadForPlayers(string scenePath, IEnumerable<INetworkPlayer> players, bool shouldClientLoadOrUnloadNormally, SceneOperation sceneOperation = SceneOperation.Normal)
{
ThrowIfScenePathEmpty(scenePath);

if (logger.LogEnabled()) logger.Log("[NetworkSceneManager] - ServerLoadForPlayers " + scenePath);
SetAllClientsNotReady(players);

SendSceneMessage(players, scenePath, shouldClientLoadOrUnloadNormally ? SceneOperation.Normal : sceneOperation);
}

/// <summary>
/// Allows server to fully load new scene or additive load in another scene.
/// </summary>
Expand Down

0 comments on commit 14283b1

Please sign in to comment.