mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Prevent AddPlayer after Additve Scene operation (#1458)
This commit is contained in:
parent
b916064856
commit
d52aa7e173
@ -810,6 +810,11 @@ public virtual void ServerChangeScene(string newSceneName)
|
|||||||
startPositions.Clear();
|
startPositions.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is only set in ClientChangeScene below...never on server.
|
||||||
|
// We need to check this in OnClientSceneChanged called from FinishLoadSceneClientOnly
|
||||||
|
// to prevent AddPlayer message after loading/unloading additive scenes
|
||||||
|
SceneOperation clientSceneOperation = SceneOperation.Normal;
|
||||||
|
|
||||||
internal void ClientChangeScene(string newSceneName, SceneOperation sceneOperation = SceneOperation.Normal, bool customHandling = false)
|
internal void ClientChangeScene(string newSceneName, SceneOperation sceneOperation = SceneOperation.Normal, bool customHandling = false)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(newSceneName))
|
if (string.IsNullOrEmpty(newSceneName))
|
||||||
@ -836,6 +841,9 @@ internal void ClientChangeScene(string newSceneName, SceneOperation sceneOperati
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cache sceneOperation so we know what was done in OnClientSceneChanged called from FinishLoadSceneClientOnly
|
||||||
|
clientSceneOperation = sceneOperation;
|
||||||
|
|
||||||
switch (sceneOperation)
|
switch (sceneOperation)
|
||||||
{
|
{
|
||||||
case SceneOperation.Normal:
|
case SceneOperation.Normal:
|
||||||
@ -1438,7 +1446,8 @@ public virtual void OnClientSceneChanged(NetworkConnection conn)
|
|||||||
// always become ready.
|
// always become ready.
|
||||||
if (!ClientScene.ready) ClientScene.Ready(conn);
|
if (!ClientScene.ready) ClientScene.Ready(conn);
|
||||||
|
|
||||||
if (autoCreatePlayer && ClientScene.localPlayer == null)
|
// Only call AddPlayer for normal scene changes, not additive load/unload
|
||||||
|
if (clientSceneOperation == SceneOperation.Normal && autoCreatePlayer && ClientScene.localPlayer == null)
|
||||||
{
|
{
|
||||||
// add player if existing one is null
|
// add player if existing one is null
|
||||||
ClientScene.AddPlayer();
|
ClientScene.AddPlayer();
|
||||||
|
Loading…
Reference in New Issue
Block a user