diff --git a/Assets/Scripts/Gameplay/GameState/ClientMainMenuState.cs b/Assets/Scripts/Gameplay/GameState/ClientMainMenuState.cs index 1f0444f1e..07a39cced 100644 --- a/Assets/Scripts/Gameplay/GameState/ClientMainMenuState.cs +++ b/Assets/Scripts/Gameplay/GameState/ClientMainMenuState.cs @@ -71,7 +71,7 @@ protected override void Configure(IContainerBuilder builder) builder.RegisterComponent(m_IPUIMediator); } - private async void TrySignIn() + async void TrySignIn() { try { @@ -88,16 +88,21 @@ private async void TrySignIn() } } - private void OnAuthSignIn() + void OnAuthSignIn() { m_SessionButton.interactable = true; m_UGSSetupTooltipDetector.enabled = false; m_SignInSpinner.SetActive(false); Debug.Log($"Signed in. Unity Player ID {AuthenticationService.Instance.PlayerId}"); + + m_LocalUser.ID = AuthenticationService.Instance.PlayerId; + + // The local SessionUser object will be hooked into UI before the LocalSession is populated during session join, so the LocalSession must know about it already when that happens. + m_LocalSession.AddUser(m_LocalUser); } - private void OnSignInFailed() + void OnSignInFailed() { if (m_SessionButton) { diff --git a/Assets/Scripts/UnityServices/Sessions/LocalSession.cs b/Assets/Scripts/UnityServices/Sessions/LocalSession.cs index 58de13f0a..878b2048c 100644 --- a/Assets/Scripts/UnityServices/Sessions/LocalSession.cs +++ b/Assets/Scripts/UnityServices/Sessions/LocalSession.cs @@ -213,9 +213,10 @@ public void ApplyRemoteData(ISession session) CopyDataFrom(info, localSessionUsers); } - public void Reset() + public void Reset(LocalSessionUser localUser) { CopyDataFrom(new SessionData(), new Dictionary()); + AddUser(localUser); } } } diff --git a/Assets/Scripts/UnityServices/Sessions/MultiplayerServicesFacade.cs b/Assets/Scripts/UnityServices/Sessions/MultiplayerServicesFacade.cs index b1e79e2d8..86de1e0b0 100644 --- a/Assets/Scripts/UnityServices/Sessions/MultiplayerServicesFacade.cs +++ b/Assets/Scripts/UnityServices/Sessions/MultiplayerServicesFacade.cs @@ -227,7 +227,7 @@ void ResetSession() { CurrentUnitySession = null; m_LocalUser?.ResetState(); - m_LocalSession?.Reset(); + m_LocalSession?.Reset(m_LocalUser); // no need to disconnect Netcode, it should already be handled by Netcode's callback to disconnect }