您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

41 行
1.1 KiB

using System;
using Unity.Services.Authentication.Internal;
namespace Unity.Services.Authentication
{
class PlayerIdComponent : IPlayerId
{
IAuthenticationService m_AuthenticationService;
public string PlayerId => m_AuthenticationService.PlayerId;
public event Action<string> PlayerIdChanged;
public PlayerIdComponent(IAuthenticationService service)
{
m_AuthenticationService = service;
m_AuthenticationService.SignedIn += OnAuthenticationSignedIn;
m_AuthenticationService.SignedOut += OnAuthenticationSignedOut;
m_AuthenticationService.SignInFailed += OnAuthenticationSignInFailed;
}
void OnAuthenticationSignInFailed(AuthenticationException error)
{
NotifyPlayerChanged();
}
void OnAuthenticationSignedOut()
{
NotifyPlayerChanged();
}
void OnAuthenticationSignedIn()
{
NotifyPlayerChanged();
}
void NotifyPlayerChanged()
{
PlayerIdChanged?.Invoke(PlayerId);
}
}
}