diff --git a/Firebase_Leaderboard/Demo/DemoUIController.cs b/Firebase_Leaderboard/Demo/DemoUIController.cs index 0191bab..f095b59 100644 --- a/Firebase_Leaderboard/Demo/DemoUIController.cs +++ b/Firebase_Leaderboard/Demo/DemoUIController.cs @@ -14,23 +14,21 @@ You may obtain a copy of the License at limitations under the License. **/ -using Firebase; -using Firebase.Database; using Firebase.Unity; -using Firebase.Unity.Editor; + using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using UnityEngine; using UnityEngine.UI; -namespace Firebase.Leaderboard.Demo { - /// - /// This class controls the UI in the demo scene, responding to events and updating - /// elements of the UI as events occur. - /// - public class DemoUIController : MonoBehaviour { +namespace Firebase.Leaderboard.Demo +{ + /// + /// This class controls the UI in the demo scene, responding to events and updating + /// elements of the UI as events occur. + /// + public class DemoUIController : MonoBehaviour { /// /// When adding batch scores, occasionally populate the UserIDInput and ScoreInput /// with one of the scores generated. For display purposes only. diff --git a/Firebase_Leaderboard/Scripts/LeaderboardController.cs b/Firebase_Leaderboard/Scripts/LeaderboardController.cs index 3d1c459..b144137 100644 --- a/Firebase_Leaderboard/Scripts/LeaderboardController.cs +++ b/Firebase_Leaderboard/Scripts/LeaderboardController.cs @@ -16,7 +16,6 @@ limitations under the License. using Firebase.Database; using Firebase.Unity; -using Firebase.Unity.Editor; using System; using System.Collections; using System.Collections.Generic; @@ -36,23 +35,6 @@ public class LeaderboardController : MonoBehaviour { /// public bool EditorAuth = true; - /// - /// Location of Editor P12 file. This must be in a base folder called "Editor Default - /// Resources." See instructions at - /// https://firebase.google.com/docs/database/unity/start#optional_editor_setup_for_restricted_access. - /// - public string EditorP12FileName; - - /// - /// Service account email used for Editor authentication after generating the P12 key file. - /// - public string EditorServiceAccountEmail; - - /// - /// Password created along with P12 key file in authentication process. - /// - public string EditorP12Password; - /// /// Subscribe to be notified when the database has been initialized. /// @@ -251,15 +233,6 @@ private void Update() { if (!initialized) { if (readyToInitialize) { FirebaseApp app = FirebaseApp.DefaultInstance; - if (EditorAuth) { - app.SetEditorP12FileName(EditorP12FileName); - app.SetEditorServiceAccountEmail(EditorServiceAccountEmail); - app.SetEditorP12Password(EditorP12Password); - } - - if (app.Options.DatabaseUrl != null) { - app.SetEditorDatabaseUrl(app.Options.DatabaseUrl); - } dbref = FirebaseDatabase.DefaultInstance.RootReference; initialized = true; diff --git a/Firebase_RemoteConfig/Scripts/RemoteConfigSyncBehaviour.cs b/Firebase_RemoteConfig/Scripts/RemoteConfigSyncBehaviour.cs index 14aec23..0618d59 100644 --- a/Firebase_RemoteConfig/Scripts/RemoteConfigSyncBehaviour.cs +++ b/Firebase_RemoteConfig/Scripts/RemoteConfigSyncBehaviour.cs @@ -137,11 +137,14 @@ public IEnumerator SyncFieldsCR() { Debug.LogWarning($"No sync targets found for {name}"); yield break; } + + var remoteConfig = FirebaseRemoteConfig.DefaultInstance; + foreach (var kv in flattenedTargets) { var sourceObject = kv.Key; var targets = kv.Value; foreach (var target in targets) { - var value = FirebaseRemoteConfig.GetValue(target.FullKeyString); + var value = remoteConfig.GetValue(target.FullKeyString); if (value.Source == ValueSource.RemoteValue) { if (target.Field.GetValue(sourceObject)?.ToString() == value.StringValue) { continue; diff --git a/Scripts/FirebaseInitializer.cs b/Scripts/FirebaseInitializer.cs index 14a2d54..44adbd4 100644 --- a/Scripts/FirebaseInitializer.cs +++ b/Scripts/FirebaseInitializer.cs @@ -32,7 +32,6 @@ public static class FirebaseInitializer { private static List activateFetchCallbacks = new List(); private static DependencyStatus dependencyStatus; private static bool initialized = false; - private static bool fetching = false; private static bool activateFetched = false; /// @@ -72,32 +71,27 @@ public static void RemoteConfigActivateFetched(Action callback, bool forceRefres } else { activateFetchCallbacks.Add(callback); } - if (!fetching) { -#if UNITY_EDITOR - var settings = FirebaseRemoteConfig.Settings; - settings.IsDeveloperMode = true; - FirebaseRemoteConfig.Settings = settings; -#endif - // Get the default values from the current SyncTargets. - var syncObjects = Resources.FindObjectsOfTypeAll(); - var syncTargets = SyncTargetManager.FindTargets(syncObjects).GetFlattenedTargets(); - var defaultValues = new Dictionary(); - foreach (var target in syncTargets.Values) { - defaultValues[target.FullKeyString] = target.Value; - } + + // Get the default values from the current SyncTargets. + var syncObjects = Resources.FindObjectsOfTypeAll(); + var syncTargets = SyncTargetManager.FindTargets(syncObjects).GetFlattenedTargets(); + var defaultValues = new Dictionary(); + foreach (var target in syncTargets.Values) { + defaultValues[target.FullKeyString] = target.Value; + } - Initialize(status => { - FirebaseRemoteConfig.SetDefaults(defaultValues); - FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero).ContinueWith(task => { + Initialize(status => { + var remoteConfig = FirebaseRemoteConfig.DefaultInstance; + remoteConfig.SetDefaultsAsync(defaultValues) + .ContinueWith(_=>{ + remoteConfig.FetchAndActivateAsync().ContinueWith(_=>{ lock (activateFetchCallbacks) { - fetching = false; - activateFetched = true; - var newlyActivated = FirebaseRemoteConfig.ActivateFetched(); - CallActivateFetchedCallbacks(); - } + activateFetched = true; + CallActivateFetchedCallbacks(); + } + }); }); - }); - } + }); } }