Skip to content

Commit cb8c469

Browse files
committed
- add type init remote config
1 parent 4d8178a commit cb8c469

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
### Add the line below to `Packages/manifest.json`
2424

25-
for version `1.0.0`
25+
for version `1.0.1`
2626
```csharp
27-
"com.wolf-package.remote-config":"https://github.com/wolf-package/remote-config-manager-unity.git#1.0.0",
27+
"com.wolf-package.remote-config":"https://github.com/wolf-package/remote-config-manager-unity.git#1.0.1",
2828
```
29-
dependency `extensions-unity-1.0.1`
29+
dependency `extensions-unity-1.0.3`
3030
```csharp
31-
"com.wolf-package.extensions":"https://github.com/wolf-package/extensions-unity.git#1.0.1",
31+
"com.wolf-package.extensions":"https://github.com/wolf-package/extensions-unity.git#1.0.3",
3232
```
3333
If you use [game-data-unity](https://github.com/wolf-package/game-data-unity), add the library below and define symbol `VIRTUESKY_DATA`
3434
```csharp

Runtime/FirebaseRemoteConfigManager.cs

+29-11
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
using UnityEditor;
66
using UnityEngine;
77
using VirtueSky.Inspector;
8-
9-
108
#if VIRTUESKY_FIREBASE
119
using Firebase;
1210
using Firebase.Extensions;
1311
#endif
14-
1512
#if VIRTUESKY_FIREBASE_REMOTECONFIG
1613
using Firebase.RemoteConfig;
1714
#endif
@@ -21,6 +18,7 @@ namespace VirtueSky.RemoteConfigs
2118
public class FirebaseRemoteConfigManager : MonoBehaviour
2219
{
2320
[SerializeField] private bool dontDestroyOnLoad;
21+
[Space, SerializeField] private TypeInitRemoteConfig typeInitRemoteConfig;
2422
#if VIRTUESKY_FIREBASE
2523
[Space, ReadOnly, SerializeField] private DependencyStatus dependencyStatus = DependencyStatus.UnavailableOther;
2624
#endif
@@ -30,6 +28,13 @@ public class FirebaseRemoteConfigManager : MonoBehaviour
3028
private bool _isFetchRemoteConfigCompleted = false;
3129
private static FirebaseRemoteConfigManager _instance;
3230

31+
#region API
32+
33+
public static bool IsFetchRemoteConfigCompleted => _instance._isFetchRemoteConfigCompleted;
34+
public static List<FirebaseRemoteConfigData> ListRemoteConfigData => _instance.listRemoteConfigData;
35+
36+
#endregion
37+
3338
private void Awake()
3439
{
3540
if (dontDestroyOnLoad)
@@ -45,18 +50,25 @@ private void Awake()
4550
{
4651
Destroy(gameObject);
4752
}
48-
}
49-
50-
#region API
5153

52-
public static bool IsFetchRemoteConfigCompleted => _instance._isFetchRemoteConfigCompleted;
53-
public static List<FirebaseRemoteConfigData> ListRemoteConfigData => _instance.listRemoteConfigData;
54+
if (typeInitRemoteConfig == TypeInitRemoteConfig.InitOnAwake)
55+
{
56+
Init();
57+
}
58+
}
5459

55-
#endregion
5660

57-
#if VIRTUESKY_FIREBASE
5861
private void Start()
5962
{
63+
if (typeInitRemoteConfig == TypeInitRemoteConfig.InitOnStart)
64+
{
65+
Init();
66+
}
67+
}
68+
69+
private void Init()
70+
{
71+
#if VIRTUESKY_FIREBASE
6072
_isFetchRemoteConfigCompleted = false;
6173
if (isSetupDefaultData)
6274
{
@@ -81,8 +93,8 @@ private void Start()
8193
dependencyStatus);
8294
}
8395
});
84-
}
8596
#endif
97+
}
8698

8799
#if VIRTUESKY_FIREBASE_REMOTECONFIG && VIRTUESKY_FIREBASE
88100
private Task FetchDataAsync()
@@ -208,4 +220,10 @@ string GetBool(bool condition)
208220
}
209221
#endif
210222
}
223+
224+
enum TypeInitRemoteConfig
225+
{
226+
InitOnAwake,
227+
InitOnStart
228+
}
211229
}

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.wolf-package.remote-config",
33
"displayName": "UnityCommon-RemoteConfig",
44
"description": "Tool support use firebase remote config for game unity",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"unity": "2021.3",
77
"category": "virtuesky",
88
"author": {
@@ -16,6 +16,6 @@
1616
"RemoteConfig"
1717
],
1818
"dependencies": {
19-
"com.wolf-package.extensions": "https://github.com/wolf-package/extensions-unity.git#1.0.1"
19+
"com.wolf-package.extensions": "https://github.com/wolf-package/extensions-unity.git#1.0.3"
2020
}
2121
}

0 commit comments

Comments
 (0)