Skip to content

feat: Added popup that tells users to set up project id if it's not set up [MTT-3265][MTT-3237] #607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Assets/BossRoom/Scenes/MainMenu.unity
Git LFS file not shown
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Unity.Services.Authentication;
using Unity.Services.Core;
using UnityEngine;

using UnityEngine.UI;

namespace Unity.Multiplayer.Samples.BossRoom.Client
{
Expand All @@ -25,13 +25,12 @@ public class ClientMainMenuState : GameStateBehaviour
[SerializeField] NameGenerationData m_NameGenerationData;
[SerializeField] LobbyUIMediator m_LobbyUIMediator;
[SerializeField] IPUIMediator m_IPUIMediator;

[SerializeField] CanvasGroup m_MainMenuButtonsCanvasGroup;
[SerializeField] Button m_LobbyButton;
[SerializeField] GameObject m_SignInSpinner;

protected override void Awake()
{
m_MainMenuButtonsCanvasGroup.interactable = false;
m_LobbyButton.interactable = false;
m_LobbyUIMediator.Hide();
base.Awake();
}
Expand All @@ -46,6 +45,15 @@ protected override void InitializeScope()
[Inject]
async void InjectDependenciesAndInitialize(AuthenticationServiceFacade authServiceFacade, LocalLobbyUser localUser, LocalLobby localLobby)
{
#if UNITY_EDITOR
if (string.IsNullOrEmpty(UnityEditor.CloudProjectSettings.projectId))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no way to check with Application.cloudProjectId? And this way it would work in builds too?

{
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.");
OnSignInFailed();
return;
}
#endif

try
{
var unityAuthenticationInitOptions = new InitializationOptions();
Expand All @@ -65,7 +73,7 @@ async void InjectDependenciesAndInitialize(AuthenticationServiceFacade authServi

void OnAuthSignIn()
{
m_MainMenuButtonsCanvasGroup.interactable = true;
m_LobbyButton.interactable = true;
m_SignInSpinner.SetActive(false);

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

void OnSignInFailed()
{
m_LobbyButton.interactable = false;
m_SignInSpinner.SetActive(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Unity.Netcode.Transports.UNET;
using Unity.Netcode.Transports.UTP;
using Unity.Services.Authentication;
using Unity.Services.Core;
using UnityEngine;
using UnityEngine.SceneManagement;

Expand Down Expand Up @@ -249,6 +250,11 @@ public void RequestDisconnect()

public string GetPlayerId()
{
if (UnityServices.State != ServicesInitializationState.Initialized)
{
return ClientPrefs.GetGuid() + ProfileManager.Profile;
}

return AuthenticationService.Instance.IsSignedIn ? AuthenticationService.Instance.PlayerId : ClientPrefs.GetGuid() + ProfileManager.Profile;
}
}
Expand Down