48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using Firebase;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class FirebaseInitializer : MonoBehaviour
|
|
{
|
|
public UnityEvent onFirebaseReady;
|
|
public static FirebaseInitializer Instance;
|
|
|
|
void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
IEnumerable Start()
|
|
{
|
|
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
|
|
{
|
|
var dependencyStatus = task.Result;
|
|
if (dependencyStatus == DependencyStatus.Available)
|
|
{
|
|
// Create and hold a reference to your FirebaseApp,
|
|
// where app is a Firebase.FirebaseApp property of your application class.
|
|
var app = FirebaseApp.DefaultInstance;
|
|
onFirebaseReady?.Invoke();
|
|
|
|
// Set a flag here to indicate whether Firebase is ready to use by your app.
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError(System.String.Format(
|
|
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
|
|
// Firebase Unity SDK is not safe to use here.
|
|
}
|
|
});
|
|
|
|
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|