using Unity.Services.Core;
using System.Threading.Tasks;
using Unity.Services.Authentication;
using UnityEngine;
using Cysharp.Threading.Tasks;


namespace Darkmatter.Presentation
{
    public class LeaderBoardInitializer : MonoBehaviour
    {
        private async void Awake()
        {
            await Init();
        }

        private async UniTask Init()
        {
            await UnityServices.InitializeAsync();
            if (!AuthenticationService.Instance.IsSignedIn)
            {
                await AuthenticationService.Instance.SignInAnonymouslyAsync();
            }
            PlayerPrefs.SetString("PlayerID", AuthenticationService.Instance.PlayerId);
            PlayerPrefs.Save();
        }
    }
}

