/// <summary> /// If the RemoteConfigSyncWindow is actively displayed, re-search scene and project hierarchy /// for SyncTargets. Setting new SyncTargets triggers rerender if SyncTargets and /// RemoteConfigData are both non-null. /// </summary> public static void RefreshSyncTargets() { if (Instance != null) { var syncObjects = Resources.FindObjectsOfTypeAll <RemoteConfigSyncBehaviour>(); SyncTargets = SyncTargetManager.FindTargets(syncObjects); Instance.UpdateUI(); } }
/// <summary> /// Calls FetchAsync and ActivateFetched on FirebaseRemoteConfig, initializing its values and /// triggering provided callbacks once. /// </summary> /// <param name="callback">Callback to schedule after RemoteConfig is initialized.</param> /// <param name="forceRefresh">If true, force refresh of RemoteConfig params.</param> public static void RemoteConfigActivateFetched(Action callback, bool forceRefresh = false) { lock (activateFetchCallbacks) { if (activateFetched && !forceRefresh) { callback(); return; } 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; } Initialize(status => { FirebaseRemoteConfig.SetDefaults(defaultValues); FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero).ContinueWith(task => { lock (activateFetchCallbacks) { fetching = false; activateFetched = true; var newlyActivated = FirebaseRemoteConfig.ActivateFetched(); CallActivateFetchedCallbacks(); } }); }); } } }