Skip to content

Commit ff04a3c

Browse files
authored
feat: Added popup that tells users to set up project id if it's not set up [MTT-3265][MTT-3237] (#607)
* Added popup that tells users to set up project id Also adjusted the flow slightly - if there's no project id, we block away the lobby UI and prevent attempts to authenticate (they'd cause errors and nuisance popups) * Also blocking the IP connection if not authenticated * Revert "Also blocking the IP connection if not authenticated" This reverts commit 154c019. * Added a check to prevent a crash with unityservices
1 parent e3a3f5a commit ff04a3c

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

Assets/BossRoom/Scenes/MainMenu.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:ae6cf7edc25f198a59ea3e6076a6bc8c8ce631b4201b26fcfc3703b523977d8e
3-
size 83887
2+
oid sha256:1514fe9b4185f0b05599f02204bdc7f84659328f5cef76abb47c1ec5b0731e4e
3+
size 84906

Assets/BossRoom/Scripts/Client/Game/State/ClientMainMenuState.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using Unity.Services.Authentication;
88
using Unity.Services.Core;
99
using UnityEngine;
10-
10+
using UnityEngine.UI;
1111

1212
namespace Unity.Multiplayer.Samples.BossRoom.Client
1313
{
@@ -25,13 +25,12 @@ public class ClientMainMenuState : GameStateBehaviour
2525
[SerializeField] NameGenerationData m_NameGenerationData;
2626
[SerializeField] LobbyUIMediator m_LobbyUIMediator;
2727
[SerializeField] IPUIMediator m_IPUIMediator;
28-
29-
[SerializeField] CanvasGroup m_MainMenuButtonsCanvasGroup;
28+
[SerializeField] Button m_LobbyButton;
3029
[SerializeField] GameObject m_SignInSpinner;
3130

3231
protected override void Awake()
3332
{
34-
m_MainMenuButtonsCanvasGroup.interactable = false;
33+
m_LobbyButton.interactable = false;
3534
m_LobbyUIMediator.Hide();
3635
base.Awake();
3736
}
@@ -46,6 +45,15 @@ protected override void InitializeScope()
4645
[Inject]
4746
async void InjectDependenciesAndInitialize(AuthenticationServiceFacade authServiceFacade, LocalLobbyUser localUser, LocalLobby localLobby)
4847
{
48+
#if UNITY_EDITOR
49+
if (string.IsNullOrEmpty(UnityEditor.CloudProjectSettings.projectId))
50+
{
51+
PopupManager.ShowPopupPanel("Unity Game Services ProjectID not set up" ,"Please follow the steps outlined in Readme to set up your project id - it is required for the services to function.");
52+
OnSignInFailed();
53+
return;
54+
}
55+
#endif
56+
4957
try
5058
{
5159
var unityAuthenticationInitOptions = new InitializationOptions();
@@ -65,7 +73,7 @@ async void InjectDependenciesAndInitialize(AuthenticationServiceFacade authServi
6573

6674
void OnAuthSignIn()
6775
{
68-
m_MainMenuButtonsCanvasGroup.interactable = true;
76+
m_LobbyButton.interactable = true;
6977
m_SignInSpinner.SetActive(false);
7078

7179
Debug.Log($"Signed in. Unity Player ID {AuthenticationService.Instance.PlayerId}");
@@ -77,6 +85,7 @@ void OnAuthSignIn()
7785

7886
void OnSignInFailed()
7987
{
88+
m_LobbyButton.interactable = false;
8089
m_SignInSpinner.SetActive(false);
8190
}
8291
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Unity.Netcode.Transports.UNET;
99
using Unity.Netcode.Transports.UTP;
1010
using Unity.Services.Authentication;
11+
using Unity.Services.Core;
1112
using UnityEngine;
1213
using UnityEngine.SceneManagement;
1314

@@ -249,6 +250,11 @@ public void RequestDisconnect()
249250

250251
public string GetPlayerId()
251252
{
253+
if (UnityServices.State != ServicesInitializationState.Initialized)
254+
{
255+
return ClientPrefs.GetGuid() + ProfileManager.Profile;
256+
}
257+
252258
return AuthenticationService.Instance.IsSignedIn ? AuthenticationService.Instance.PlayerId : ClientPrefs.GetGuid() + ProfileManager.Profile;
253259
}
254260
}

0 commit comments

Comments
 (0)