Snaparazzi/Assets/Scripts/FirebaseInitializer.cs

47 lines
1.3 KiB
C#
Raw Normal View History

2024-01-26 22:51:40 +00:00
using Firebase;
using System.Collections;
using System.Collections.Generic;
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
void Start()
{
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
{
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available)
{
// Create and hold a reference to your FirebaseApp,
// where app is a Firebase.FirebaseApp property of your application class.
var app = Firebase.FirebaseApp.DefaultInstance;
onFirebaseReady?.Invoke();
// Set a flag here to indicate whether Firebase is ready to use by your app.
}
else
{
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
// Firebase Unity SDK is not safe to use here.
}
});
}
// Update is called once per frame
void Update()
{
}
}