使用匿名登录
Implement anonymous sign-in to create new players without requiring any sign-in credentials or player input.
阅读时间1 分钟最后更新于 1 个月前
匿名登录会为游戏创建一个新玩家,而无需玩家输入任何信息。玩家可以通过这种方法快速开启游戏。 如果会话令牌已经缓存到 SDK 上,请使用
SignInAnonymouslyAsync()成功执行匿名登录后,建议将其关联到至少一家受支持的身份提供商,让您的玩家能够在需要时使用其他设备继续游戏或恢复其帐户。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 (AuthenticationException ex) { // Compare error code to AuthenticationErrorCodes // Notify the player with the proper error message Debug.LogException(ex); } catch (RequestFailedException ex) { // Compare error code to CommonErrorCodes // Notify the player with the proper error message Debug.LogException(ex); }}