「Unity/Firebase/RemoteConfig」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→値取得) |
(→ローカルで値取得) |
||
| 行35: | 行35: | ||
defaults.Add("propertyname_string", "default local string"); | defaults.Add("propertyname_string", "default local string"); | ||
Debug.Log("hoge=" + Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("propertyname_string").StringValue); // default local string | Debug.Log("hoge=" + Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("propertyname_string").StringValue); // default local string | ||
| + | </pre> | ||
| + | |||
| + | ==firebase側値取得== | ||
| + | firebase1=hogehogeをfirebaseのRemoteConfigに登録しておく | ||
| + | <pre> | ||
| + | void Start() | ||
| + | { | ||
| + | var settings = Firebase.RemoteConfig.FirebaseRemoteConfig.Settings; | ||
| + | settings.IsDeveloperMode = true; | ||
| + | Firebase.RemoteConfig.FirebaseRemoteConfig.Settings = settings; | ||
| + | Debug.Log("propertyname_string=" + Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("propertyname_string").StringValue); | ||
| + | Task fetchTask = Firebase.RemoteConfig.FirebaseRemoteConfig.FetchAsync(new TimeSpan(0)); | ||
| + | fetchTask.ContinueWith(Firebase1FetchComplete); | ||
| + | } | ||
| + | void Firebase1FetchComplete(Task fetchTask) | ||
| + | { | ||
| + | switch (Firebase.RemoteConfig.FirebaseRemoteConfig.Info.LastFetchStatus) | ||
| + | { | ||
| + | case Firebase.RemoteConfig.LastFetchStatus.Success: | ||
| + | Firebase.RemoteConfig.FirebaseRemoteConfig.ActivateFetched(); | ||
| + | Debug.Log("firebase1=" + Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("firebase1").StringValue); // hogehoge | ||
| + | break; | ||
| + | } | ||
| + | } | ||
</pre> | </pre> | ||
==firebase公式RemoteConfigメソッド== | ==firebase公式RemoteConfigメソッド== | ||
https://firebase.google.com/docs/reference/unity/struct/firebase/remote-config/config-value.html?hl=ja#struct_firebase_1_1_remote_config_1_1_config_value | https://firebase.google.com/docs/reference/unity/struct/firebase/remote-config/config-value.html?hl=ja#struct_firebase_1_1_remote_config_1_1_config_value | ||
2019年5月28日 (火) 12:20時点における版
目次
Firebase設定
unity/Firebase/基本 [ショートカット]
RemoteConfigインストール
FirebaseRemoteConfig.unitypackageをAssets/Importからインストールする
Helloworld
公式 https://firebase.google.com/docs/remote-config/use-config-unity?hl=ja
System.Collections.Generic.Dictionary defaults =
new System.Collections.Generic.Dictionary();
// These are the values that are used if we haven't fetched data from the
// service yet, or if we ask for values that the service doesn't have:
defaults.Add("propertyname_string", "default local string");
defaults.Add("propertyname_int", 1);
defaults.Add("propertyname_float", 1.0);
defaults.Add("propertyname_bool", false);
Firebase.RemoteConfig.FirebaseRemoteConfig.SetDefaults(defaults);
error CS0305: Using the generic type 'Dictionary<TKey, TValue>' requires 2 type argumentsエラー
Dictionary defaults 部分で、error CS0305: Using the generic type 'Dictionary<TKey, TValue>' requires 2 type argumentsエラーがでる。
-System.Collections.Generic.Dictionary defaults = new System.Collections.Generic.Dictionary(); +System.Collections.Dictionary<string, object> defaults = new System.Collections.Dictionary<string, object>();
ローカルで値取得
Dictionary<string, object> defaults = new Dictionary<string, object>();
defaults.Add("propertyname_string", "default local string");
Debug.Log("hoge=" + Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("propertyname_string").StringValue); // default local string
firebase側値取得
firebase1=hogehogeをfirebaseのRemoteConfigに登録しておく
void Start()
{
var settings = Firebase.RemoteConfig.FirebaseRemoteConfig.Settings;
settings.IsDeveloperMode = true;
Firebase.RemoteConfig.FirebaseRemoteConfig.Settings = settings;
Debug.Log("propertyname_string=" + Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("propertyname_string").StringValue);
Task fetchTask = Firebase.RemoteConfig.FirebaseRemoteConfig.FetchAsync(new TimeSpan(0));
fetchTask.ContinueWith(Firebase1FetchComplete);
}
void Firebase1FetchComplete(Task fetchTask)
{
switch (Firebase.RemoteConfig.FirebaseRemoteConfig.Info.LastFetchStatus)
{
case Firebase.RemoteConfig.LastFetchStatus.Success:
Firebase.RemoteConfig.FirebaseRemoteConfig.ActivateFetched();
Debug.Log("firebase1=" + Firebase.RemoteConfig.FirebaseRemoteConfig.GetValue("firebase1").StringValue); // hogehoge
break;
}
}
