Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions Firebase_Leaderboard/Demo/DemoUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/// <summary>
/// This class controls the UI in the demo scene, responding to events and updating
/// elements of the UI as events occur.
/// </summary>
public class DemoUIController : MonoBehaviour {
namespace Firebase.Leaderboard.Demo
{
/// <summary>
/// This class controls the UI in the demo scene, responding to events and updating
/// elements of the UI as events occur.
/// </summary>
public class DemoUIController : MonoBehaviour {
/// <summary>
/// When adding batch scores, occasionally populate the UserIDInput and ScoreInput
/// with one of the scores generated. For display purposes only.
Expand Down
27 changes: 0 additions & 27 deletions Firebase_Leaderboard/Scripts/LeaderboardController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,23 +35,6 @@ public class LeaderboardController : MonoBehaviour {
/// </summary>
public bool EditorAuth = true;

/// <summary>
/// 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.
/// </summary>
public string EditorP12FileName;

/// <summary>
/// Service account email used for Editor authentication after generating the P12 key file.
/// </summary>
public string EditorServiceAccountEmail;

/// <summary>
/// Password created along with P12 key file in authentication process.
/// </summary>
public string EditorP12Password;

/// <summary>
/// Subscribe to be notified when the database has been initialized.
/// </summary>
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion Firebase_RemoteConfig/Scripts/RemoteConfigSyncBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
42 changes: 18 additions & 24 deletions Scripts/FirebaseInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public static class FirebaseInitializer {
private static List<Action> activateFetchCallbacks = new List<Action>();
private static DependencyStatus dependencyStatus;
private static bool initialized = false;
private static bool fetching = false;
private static bool activateFetched = false;

/// <summary>
Expand Down Expand Up @@ -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<RemoteConfigSyncBehaviour>();
var syncTargets = SyncTargetManager.FindTargets(syncObjects).GetFlattenedTargets();
var defaultValues = new Dictionary<string, object>();
foreach (var target in syncTargets.Values) {
defaultValues[target.FullKeyString] = target.Value;
}

// Get the default values from the current SyncTargets.
var syncObjects = Resources.FindObjectsOfTypeAll<RemoteConfigSyncBehaviour>();
var syncTargets = SyncTargetManager.FindTargets(syncObjects).GetFlattenedTargets();
var defaultValues = new Dictionary<string, object>();
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();
}
});
});
});
}
});
}
}

Expand Down