fix(NetworkManager): offlineSceneLoadDelaySeconds -> offlineSceneLoadDelay and Range 0-60

This commit is contained in:
MrGadget 2024-07-26 16:21:41 -04:00
parent bc9329a825
commit bb552f8a54

View File

@ -76,8 +76,8 @@ public class NetworkManager : MonoBehaviour
[Tooltip("Scene that Mirror will switch to when the server is started. Clients will recieve a Scene Message to load the server's current scene when they connect.")]
public string onlineScene = "";
[Tooltip("Optional delay that can be used after disconnecting to show a 'Connection lost...' message or similar before loading the offline scene, which may take a long time in big projects.")]
public float offlineSceneLoadDelaySeconds = 0;
[Range(0, 60), Tooltip("Optional delay that can be used after disconnecting to show a 'Connection lost...' message or similar before loading the offline scene, which may take a long time in big projects.")]
public float offlineSceneLoadDelay = 0;
// transport layer
[Header("Network Info")]
@ -1335,9 +1335,7 @@ void OnClientDisconnectInternal()
// Check loadingSceneAsync to ensure we don't double-invoke the scene change.
// Check if NetworkServer.active because we can get here via Disconnect before server has started to change scenes.
if (!string.IsNullOrWhiteSpace(offlineScene) && !Utils.IsSceneActive(offlineScene) && loadingSceneAsync == null && !NetworkServer.active)
{
Invoke(nameof(ClientChangeOfflineScene), offlineSceneLoadDelaySeconds);
}
Invoke(nameof(ClientChangeOfflineScene), offlineSceneLoadDelay);
networkSceneName = "";
}
@ -1361,9 +1359,7 @@ void OnClientSceneInternal(SceneMessage msg)
// This needs to run for host client too. NetworkServer.active is checked there
if (NetworkClient.isConnected)
{
ClientChangeScene(msg.sceneName, msg.sceneOperation, msg.customHandling);
}
}
/// <summary>Called on the server when a new client connects.</summary>