aula: Autenticação Anônima
modulo: Construção extrema
o codigo está igual ao que o professor fez, verifiquei varias vezes, mas mesmo assim da erro na linha 16, no primeiro if
using System;
using System.Threading.Tasks;
using Unity.Services.Authentication;
using Unity.Services.Core;
using UnityEngine;
public class CloudServices : MonoBehaviour
{
[SerializeField] private GameObject erroLoginPopup;
private async void Awake()
{
try
{
if (AuthenticationService.Instance.IsSignedIn)
{
return;
}
await UnityServices.InitializeAsync();
await SignInAnonymouslyAsync();
}
catch (Exception e)
{
Debug.LogException(e);
}
}
public async Task SignInAnonymouslyAsync()
{
try
{
await AuthenticationService.Instance.SignInAnonymouslyAsync();
Debug.Log("Sign in anonymously succeeded!");
// Shows how to get the playerID
Debug.Log($"PlayerID: {AuthenticationService.Instance.PlayerId}");
}
catch
{
erroLoginPopup.SetActive(true);
}
}
public void TentarLoginNovamente()
{
erroLoginPopup.SetActive(false);
SignInAnonymouslyAsync();
}
}