Skip to content

Commit

Permalink
Merge pull request #2 from Unity-Technologies/Update/disabling-services
Browse files Browse the repository at this point in the history
Adding warnings for services when these are disabled
  • Loading branch information
julianunity authored Jun 8, 2023
2 parents 37fa6c7 + 78c9213 commit 4ef9f87
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 9 deletions.
15 changes: 13 additions & 2 deletions Assets/Scripts/Gameplay/UI/MonoBehaviours/MainMenu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,20 @@ private async void Awake()
Destroy(gameObject);
return;
}

MatchMakingConnector = new MatchMakingConnector(m_ServerSettings);
await MatchMakingConnector.Init();
if (string.IsNullOrEmpty(Application.cloudProjectId))
{
Debug.LogWarning($"To use Unity's dashboard services, " +
"you need to link your Unity project to a project ID. " +
"To do this, go to Project Settings to select your organization, " +
"select your project and then link a project ID. " +
"You also need to make sure your organization has access to the required products. " +
"Visit https://dashboard.unity3d.com to sign up.");
}
else
{
await MatchMakingConnector.Init();
}
}

private void OnDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class MatchMakingConnector
public MatchMakingConnector(MultiplayerServerSettings ServerSettings)
{
m_ServerSettings = ServerSettings;
m_DefaultName = Environment.UserName.ToUpper();
}

public async Task Init()
Expand All @@ -43,8 +44,6 @@ public async Task Init()
#if UNITY_SERVER && !UNITY_EDITOR
return;
#endif
m_DefaultName = Environment.UserName.ToUpper();

#region ServiceSignin

m_ProfileService = new PlayerAuthentication();
Expand All @@ -59,6 +58,17 @@ public async Task Matchmake()
Debug.Log("Beginning Matchmaking.");
m_ConnectionStatusLabel.text = "Beginning Matchmaking.";

if (string.IsNullOrEmpty(Application.cloudProjectId))
{
Debug.LogWarning($"To use Unity's dashboard services, " +
"you need to link your Unity project to a project ID. " +
"To do this, go to Project Settings to select your organization, " +
"select your project and then link a project ID. " +
"You also need to make sure your organization has access to the required products. " +
"Visit https://dashboard.unity3d.com to sign up.");
return;
}

try
{
var matchmakingResult = await m_Matchmaker.Matchmake(m_ProfileService.LocalPlayer);
Expand Down
10 changes: 9 additions & 1 deletion Assets/Scripts/Gameplay/Vivox/MonoBehaviours/VivoxManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ private void Awake()
Destroy(this);
return;
}

if (string.IsNullOrEmpty(Application.cloudProjectId))
{
Debug.LogWarning(VivoxEvents.k_SetupProjectInTheCloud);
Destroy(this);
return;
}

Instance = this;
m_IsReady = false;
Expand All @@ -39,7 +46,8 @@ private void Awake()

private async void Start()
{
// if the Unity project is not linked to a Unity services project.
// if the Unity project is not linked to a Unity services project.
Debug.Log($"vivox applciation project {Application.cloudProjectId}");
if (string.IsNullOrEmpty(Application.cloudProjectId))
{
Debug.LogWarning(VivoxEvents.k_SetupProjectInTheCloud);
Expand Down
5 changes: 5 additions & 0 deletions Assets/Scripts/Gameplay/Vivox/MonoBehaviours/VivoxPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ private void Awake()

private void Start()
{
if(VivoxManager.Instance == null || VivoxSession == null)
return;

VivoxSession.OnUserLoggedInEvent += ShowPanel;
VivoxSession.OnUserLoggedInEvent += OnUserLoggedIn;
VivoxSession.OnUserLoggedOutEvent += OnUserLoggedOut;
Expand All @@ -40,6 +43,8 @@ private void Start()

private void OnDestroy()
{
if (VivoxManager.Instance == null || VivoxSession == null)
return;
VivoxSession.OnUserLoggedInEvent -= OnUserLoggedIn;
VivoxSession.OnUserLoggedOutEvent -= OnUserLoggedOut;
VivoxSession.OnUserLoggedOutEvent -= HidePanel;
Expand Down
14 changes: 10 additions & 4 deletions Assets/Scripts/Gameplay/Vivox/MonoBehaviours/VivoxPlayerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,20 @@ private void Update()

private void Start()
{
VivoxManager.Instance.Channel.OnParticipantAddedEvent += OnParticipantAdded;
VivoxManager.Instance.Channel.OnParticipantRemovedEvent += OnParticipantRemoved;
if (VivoxManager.Instance != null && VivoxManager.Instance.Channel != null)
{
VivoxManager.Instance.Channel.OnParticipantAddedEvent += OnParticipantAdded;
VivoxManager.Instance.Channel.OnParticipantRemovedEvent += OnParticipantRemoved;
}
}

private void OnDestroy()
{
VivoxManager.Instance.Channel.OnParticipantAddedEvent -= OnParticipantAdded;
VivoxManager.Instance.Channel.OnParticipantRemovedEvent -= OnParticipantRemoved;
if (VivoxManager.Instance != null && VivoxManager.Instance.Channel != null)
{
VivoxManager.Instance.Channel.OnParticipantAddedEvent -= OnParticipantAdded;
VivoxManager.Instance.Channel.OnParticipantRemovedEvent -= OnParticipantRemoved;
}
}

private void OnParticipantAdded(string username, ChannelId channel, IParticipant participant)
Expand Down

0 comments on commit 4ef9f87

Please sign in to comment.