Skip to content

Configuration

高凯 edited this page Dec 19, 2017 · 1 revision

Editor tool

Open the configuration editor Window -> 配置编辑器(Configuration Editor)

In the 新增配置(new configuration tab), enter the 配置名(configuration name) to create a configuration table, the configuration table will be placed Resources/Config directory
After the build in the current configuration options, select the configuration you just created, edit the fields you want

translation
Field Type -> 字段类型
Field Content -> 字段内容

API

ConfigManager
public static Dictionary <string, SingleField> GetData (string ConfigName) Get a configuration object

SingleField
public int GetInt () Get an Int
public int GetFloat () Gets a Float
public bool GetBool () Get a Bool
public string GetString () Get a String
public string [] GetStringArray () Gets a String array
public Vector2 GetVector2 () Get a Vector2
public Vector3 GetVector3 () Get a Vector3
public Color GetColor () Get a Color
public T GetEnum <T> () where T: struct Get an enumeration

Example

    void LoadConfig ()
    {
        if (ConfigManager.GetIsExistConfig ("LanguageConfig"))
        {
            Dictionary <string, SingleField> config = ConfigManager.GetData ("LanguageConfig");

            if (config.ContainsKey ("DefaultLanguage"))
            {
                SystemLanguage defaultLanguage = config ["DefaultLanguage"]. GetEnum <SystemLanguage> ();
            }
        }
    }
Clone this wiki locally