55using UnityEditor ;
66using UnityEngine ;
77using VirtueSky . Inspector ;
8-
9-
108#if VIRTUESKY_FIREBASE
119using Firebase ;
1210using Firebase . Extensions ;
1311#endif
14-
1512#if VIRTUESKY_FIREBASE_REMOTECONFIG
1613using 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}
0 commit comments