-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirebaseRemoteConfigHelper.cs
More file actions
58 lines (52 loc) · 2.3 KB
/
FirebaseRemoteConfigHelper.cs
File metadata and controls
58 lines (52 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#if UNITY_EDITOR
using UnityEngine;
using System.Reflection;
using Firebase.RemoteConfig;
using System.Collections.Generic;
namespace RimuruDev
{
public static class FirebaseRemoteConfigHelper
{
public static void PrintRemoteConfigCache()
{
var type = typeof(FirebaseRemoteConfig);
var field = type.GetField("remoteConfigByInstanceKey", BindingFlags.Static | BindingFlags.NonPublic);
if (field != null)
{
if (field.GetValue(null) is IDictionary<string, FirebaseRemoteConfig> dictionary)
{
Debug.Log($"<color=yellow>RemoteConfig cache count: {dictionary.Count}</color>");
foreach (var kvp in dictionary)
Debug.Log($"<color=yellow>Key: {kvp.Key}, Instance: {kvp.Value}</color>");
}
else
Debug.LogWarning("<color=yellow>Dictionary remoteConfigByInstanceKey == null.</color>");
}
else
Debug.LogWarning("<color=red>Field remoteConfigByInstanceKey not found.</color>");
}
public static void ClearRemoteConfigCache()
{
// NOTE:
// Словарик забетонирован, по этому пришлось действовать немного по плохому.
// *
// Так выглядит словарик remoteConfigByInstanceKey у FirebaseRemoteConfig:
//
// public sealed class FirebaseRemoteConfig
// {
// private static readonly Dictionary<string, FirebaseRemoteConfig> remoteConfigByInstanceKey = new Dictionary<string, FirebaseRemoteConfig>();
// }
var type = typeof(FirebaseRemoteConfig);
var field = type.GetField("remoteConfigByInstanceKey", BindingFlags.Static | BindingFlags.NonPublic);
if (field != null)
{
var dictionary = field.GetValue(null) as IDictionary<string, FirebaseRemoteConfig>;
dictionary?.Clear();
Debug.Log("<color=yellow>FirebaseRemoteConfig cache cleared.</color>");
}
else
Debug.LogWarning("<color=red>Field remoteConfigByInstanceKey not found.</color>");
}
}
}
#endif