39 lines
899 B
C#
39 lines
899 B
C#
using System.Threading.Tasks;
|
|
using Unity.Services.Authentication;
|
|
using Unity.Services.Core;
|
|
using UnityEngine;
|
|
|
|
public class LeaderBoardInitializer : MonoBehaviour
|
|
{
|
|
public LeaderBoardManager leaderBoardManager;
|
|
public LeaderBoardUI leaderBoardUI;
|
|
private async void Awake()
|
|
{
|
|
await Init();
|
|
}
|
|
|
|
private async Task Init()
|
|
{
|
|
await UnityServices.InitializeAsync();
|
|
if(!AuthenticationService.Instance.IsSignedIn)
|
|
{
|
|
await AuthenticationService.Instance.SignInAnonymouslyAsync();
|
|
}
|
|
Debug.Log("Signed in as :" + AuthenticationService.Instance.PlayerId);
|
|
Invoke("SubmitScore", 5f);
|
|
}
|
|
|
|
public void SubmitScore()
|
|
{
|
|
leaderBoardManager.SubmitScore(55);
|
|
Invoke("CallLeaderBoardUI", 5f);
|
|
}
|
|
|
|
public void CallLeaderBoardUI()
|
|
{
|
|
leaderBoardUI.LoadLeaderBoard();
|
|
}
|
|
|
|
|
|
}
|