Example #1
0
    private static Setting LoadSetting(string path)
    {
        if (!AssetUtil.FileExist(path))
        {
#if UNITY_EDITOR
            byte[] _data    = AssetUtil.ReadFile("editor_config/setting.json");
            string savePath = Application.streamingAssetsPath + "/setting.json";
            _data = EnCode(_data);
            File.WriteAllBytes(savePath, _data);
            path = savePath;
#else
            throw new Exception("请执行Setting->Build");
#endif
        }

        string str = GetSettingStr(path);

        Setting setting;
        if (!string.IsNullOrEmpty(str))
        {
            setting = JsonUtility.FromJson <Setting>(str);
        }
        else
        {
            setting = new Setting();
        }
        return(setting);
    }