public void UpdateRemoteSettings()
        {
            Type myType = this.GetType();

            FieldInfo[] fields = myType.GetFields(
                BindingFlags.NonPublic | BindingFlags.Public |
                BindingFlags.Instance);

            foreach (var field in fields)
            {
                Entry entry = GetEntryFromField(this, field);


                if (RemoteSettings.HasKey(entry.key))
                {
                    bool valueChanged = false;

                    //Type doesn't work with a switch, so let's do it this way
                    if (entry.type == "bool")
                    {
                        bool value = RemoteSettings.GetBool(entry.key);

                        if (value != (bool)field.GetValue(this))
                        {
                            valueChanged = true;
                        }

                        field.SetValue(this, value);
                    }
                    else if (entry.type == "float")
                    {
                        float value = RemoteSettings.GetFloat(entry.key);

                        if (value != (float)field.GetValue(this))
                        {
                            valueChanged = true;
                        }

                        field.SetValue(this, value);
                    }
                    else if (entry.type == "int")
                    {
                        int value = RemoteSettings.GetInt(entry.key);

                        if (value != (int)field.GetValue(this))
                        {
                            valueChanged = true;
                        }

                        field.SetValue(this, value);
                    }
                    else if (entry.type == "string")
                    {
                        string value = RemoteSettings.GetString(entry.key);

                        if (value != (string)field.GetValue(this))
                        {
                            valueChanged = true;
                        }

                        field.SetValue(this, value);
                    }

                    if (valueChanged)
                    {
                        Debug.LogFormat("<color=cyan>Remote Settings</color> # Update field {0} of {1}.", entry.key, this.name);
                    }
                }

                else
                {
                    Debug.LogFormat("<color=cyan>Remote Settings</color> # <color=red>No key</color> for field {0} of {1}.", entry.key, this.name);
                }
            }
        }
示例#2
0
 public bool HasKey(string key)
 {
     return(RemoteSettings.HasKey(key));
 }