From b6865b3c54ece79c0044444b15b03c39eb7f50cc Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Fri, 26 Jan 2024 23:51:40 +0100 Subject: [PATCH] feat: add Firebase Initializer --- Assets/Scripts/FirebaseInitializer.cs | 46 ++++++++++++++++++++++ Assets/Scripts/FirebaseInitializer.cs.meta | 11 ++++++ Packages/manifest.json | 1 + Packages/packages-lock.json | 26 ++++++++++++ ProjectSettings/GvhProjectSettings.xml | 2 - 5 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 Assets/Scripts/FirebaseInitializer.cs create mode 100644 Assets/Scripts/FirebaseInitializer.cs.meta diff --git a/Assets/Scripts/FirebaseInitializer.cs b/Assets/Scripts/FirebaseInitializer.cs new file mode 100644 index 0000000..0f197ed --- /dev/null +++ b/Assets/Scripts/FirebaseInitializer.cs @@ -0,0 +1,46 @@ +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() + { + + } +} diff --git a/Assets/Scripts/FirebaseInitializer.cs.meta b/Assets/Scripts/FirebaseInitializer.cs.meta new file mode 100644 index 0000000..15b1e53 --- /dev/null +++ b/Assets/Scripts/FirebaseInitializer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 153bd176c0ad8f82692512264f5245ba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/manifest.json b/Packages/manifest.json index 9956248..3ba5bff 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -4,6 +4,7 @@ "com.unity.feature.development": "1.0.1", "com.unity.textmeshpro": "3.0.6", "com.unity.timeline": "1.7.6", + "com.unity.toolchain.linux-x86_64": "2.0.6", "com.unity.ugui": "1.0.0", "com.unity.visualscripting": "1.9.1", "com.unity.modules.ai": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 778c29e..f6f25fe 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -74,6 +74,22 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.sysroot": { + "version": "2.0.7", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.sysroot.linux-x86_64": { + "version": "2.0.6", + "depth": 1, + "source": "registry", + "dependencies": { + "com.unity.sysroot": "2.0.7" + }, + "url": "https://packages.unity.com" + }, "com.unity.test-framework": { "version": "1.1.33", "depth": 1, @@ -116,6 +132,16 @@ }, "url": "https://packages.unity.com" }, + "com.unity.toolchain.linux-x86_64": { + "version": "2.0.6", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.sysroot": "2.0.7", + "com.unity.sysroot.linux-x86_64": "2.0.6" + }, + "url": "https://packages.unity.com" + }, "com.unity.ugui": { "version": "1.0.0", "depth": 0, diff --git a/ProjectSettings/GvhProjectSettings.xml b/ProjectSettings/GvhProjectSettings.xml index 9e22339..47fce63 100644 --- a/ProjectSettings/GvhProjectSettings.xml +++ b/ProjectSettings/GvhProjectSettings.xml @@ -1,7 +1,5 @@ - -