Skip to content

Commit 5f75bc9

Browse files
committed
Added condition to increase delay before fadeout only for late joins
1 parent f898a2c commit 5f75bc9

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

Assets/BossRoom/Scripts/Shared/Net/ConnectionManagement/GameNetPortal.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using Unity.Multiplayer.Samples.BossRoom.Client;
33
using Unity.Multiplayer.Samples.BossRoom.Server;
4-
using Unity.Multiplayer.Samples.Utilities;
54
using Unity.Multiplayer.Samples.BossRoom.Shared.Infrastructure;
65
using Unity.Multiplayer.Samples.BossRoom.Shared.Net.UnityServices.Lobbies;
76
using Unity.Netcode;

Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/ClientLoadingScreen.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ClientLoadingScreen : MonoBehaviour
1616
CanvasGroup m_CanvasGroup;
1717

1818
[SerializeField]
19-
float m_DelayBeforeFadeOut = 1;
19+
float m_DelayBeforeFadeOut = 0.5f;
2020

2121
[SerializeField]
2222
float m_FadeOutDuration = 1;
@@ -51,7 +51,7 @@ void Update()
5151
}
5252
}
5353

54-
public void StopLoadingScreen()
54+
public void StopLoadingScreen(bool isLateJoin = false)
5555
{
5656
if (m_LoadingScreenRunning)
5757
{
@@ -80,11 +80,12 @@ public void UpdateLoadingScreen(string sceneName, AsyncOperation loadOperation)
8080
}
8181
}
8282

83-
IEnumerator FadeOutCoroutine()
83+
IEnumerator FadeOutCoroutine(bool isLateJoin = false)
8484
{
8585
m_ProgressBar.value = 1;
8686
float currentTime = 0;
87-
while (currentTime < m_DelayBeforeFadeOut)
87+
float delayBeforeFadeOut = isLateJoin ? 2 * m_DelayBeforeFadeOut : m_DelayBeforeFadeOut;
88+
while (currentTime < delayBeforeFadeOut)
8889
{
8990
yield return null;
9091
currentTime += Time.deltaTime;

Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/SceneLoaderWrapper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ void OnSceneEvent(SceneEvent sceneEvent)
117117
case SceneEventType.LoadEventCompleted: // Server told client that all clients finished loading a scene
118118
m_ClientLoadingScreen.StopLoadingScreen();
119119
break;
120-
case SceneEventType.SynchronizeComplete: // Client told server that they finished synchronizing
121-
// Send client RPC to make sure the client stops the loading screen after the server handles what it needs to after the client finished synchronizing
122-
m_ClientLoadingScreen.StopLoadingScreen();
120+
case SceneEventType.SynchronizeComplete: // Client has finished synchronizing
121+
m_ClientLoadingScreen.StopLoadingScreen(true);
123122
break;
124123
}
125124
}

0 commit comments

Comments
 (0)