반응형
파이어베이스 SDK 다운로드
압축 푼 뒤
dotnet4 / FirebaseAuth.unitypackage 설치
- 코드 작성
using Firebase;
using Firebase.Extensions;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FirebaseAuth : MonoBehaviour
{
void Start()
{
FirebaseInit();
}
void FirebaseInit()
{
StartCoroutine(FirebaseLoginCoroutine());
}
IEnumerator FirebaseLoginCoroutine()
{
yield return null;
Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
auth.SignInAnonymouslyAsync().ContinueWithOnMainThread(task =>
{
if (task.IsCanceled)
{
Debug.LogError("SignInAnonymouslyAsync was canceled.");
return;
}
if (task.IsFaulted)
{
Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception);
return;
}
Firebase.Auth.FirebaseUser newUser = task.Result;
Debug.LogFormat("User signed in successfully: {0} ({1})",
newUser.DisplayName, newUser.UserId);
});
}
}
Api 참고
참고할만한 글
반응형