Skip to content

Commit 953ed0e

Browse files
fix: resetting local user on profile change [MTT-11948] (#916)
* resetting local user on profile change * cleanup * formatting
1 parent b4afa28 commit 953ed0e

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

Assets/Scripts/Gameplay/GameState/ClientMainMenuState.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected override void Configure(IContainerBuilder builder)
7171
builder.RegisterComponent(m_IPUIMediator);
7272
}
7373

74-
private async void TrySignIn()
74+
async void TrySignIn()
7575
{
7676
try
7777
{
@@ -88,16 +88,21 @@ private async void TrySignIn()
8888
}
8989
}
9090

91-
private void OnAuthSignIn()
91+
void OnAuthSignIn()
9292
{
9393
m_SessionButton.interactable = true;
9494
m_UGSSetupTooltipDetector.enabled = false;
9595
m_SignInSpinner.SetActive(false);
9696

9797
Debug.Log($"Signed in. Unity Player ID {AuthenticationService.Instance.PlayerId}");
98+
99+
m_LocalUser.ID = AuthenticationService.Instance.PlayerId;
100+
101+
// 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.
102+
m_LocalSession.AddUser(m_LocalUser);
98103
}
99104

100-
private void OnSignInFailed()
105+
void OnSignInFailed()
101106
{
102107
if (m_SessionButton)
103108
{

Assets/Scripts/UnityServices/Sessions/LocalSession.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,10 @@ public void ApplyRemoteData(ISession session)
213213
CopyDataFrom(info, localSessionUsers);
214214
}
215215

216-
public void Reset()
216+
public void Reset(LocalSessionUser localUser)
217217
{
218218
CopyDataFrom(new SessionData(), new Dictionary<string, LocalSessionUser>());
219+
AddUser(localUser);
219220
}
220221
}
221222
}

Assets/Scripts/UnityServices/Sessions/MultiplayerServicesFacade.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void ResetSession()
227227
{
228228
CurrentUnitySession = null;
229229
m_LocalUser?.ResetState();
230-
m_LocalSession?.Reset();
230+
m_LocalSession?.Reset(m_LocalUser);
231231

232232
// no need to disconnect Netcode, it should already be handled by Netcode's callback to disconnect
233233
}

0 commit comments

Comments
 (0)