Esempio n. 1
0
        private void Init()
        {
            config = GameBootConfig.LoadConfig();
            if (config == null)
            {
                config = new GameBootConfig();
            }

            allModules.Clear();
            Type[] types = ReflectionUtils.GetChildTypes(typeof(AppModuleBase));
            foreach (var type in types)
            {
                if (type.IsAbstract)
                {
                    continue;
                }

                AppModuleBase appModule = null;

                if (config.allAppModuleSetting.ContainsKey(type.Name))
                {
                    appModule = (AppModuleBase)ReflectionUtils.CreateDefultInstance(type);
                    appModule = (AppModuleBase)config.allAppModuleSetting[type.Name].GetValue(appModule);
                }
                else
                {
                    appModule = (AppModuleBase)ReflectionUtils.CreateDefultInstance(type);
                }
                allModules.Add(type, appModule);
            }
        }
Esempio n. 2
0
        private void Save()
        {
            config.allAppModuleSetting.Clear();
            foreach (var item in allModules)
            {
                ClassValue value = new ClassValue(item.Value, false);
                config.allAppModuleSetting.Add(item.Key.Name, value);
            }

            GameBootConfig.Save(config);
        }
    void IPreprocessBuildWithReport.OnPreprocessBuild(BuildReport report)
    {
        Debug.Log("OnPreprocessBuild");

        GameBootConfig config = GameBootConfig.LoadConfig();

        if (config != null)
        {
            config.buildTime = DateTime.Now.Ticks;
            GameBootConfig.Save(config);
            AssetDatabase.Refresh();
            Debug.Log("OnPreprocessBuild GameBootConfig:" + config.buildTime);
        }
    }
    public static GameBootConfig LoadConfig()
    {
        string jsonData = null;

        if (Application.isEditor)
        {
            jsonData = ResourcesLoadConfig();
        }
        else
        {
            string fileName           = ConfigFileName;
            string persistentDataPath = Application.persistentDataPath + "/Configs/" + fileName + ".txt";
            jsonData = ResourcesLoadConfig();
            if (!File.Exists(persistentDataPath))
            {
                if (string.IsNullOrEmpty(jsonData))
                {
                    return(null);
                }
                else
                {
                    Debug.Log("GameBootConfig写入沙盒");
                    FileUtils.CreateTextFile(persistentDataPath, jsonData);
                }
            }
            else
            {
                //比较包里的配置和沙河路径的配置buildTime,当不一致时 以包里的覆盖沙盒的,否则使用沙盒路径的(便于保存修改)
                GameBootConfig resConfig = JsonUtils.FromJson <GameBootConfig>(jsonData);

                string         perJsonData = FileUtils.LoadTextFileByPath(persistentDataPath);
                GameBootConfig perConfig   = JsonUtils.FromJson <GameBootConfig>(perJsonData);

                if (perConfig == null || perConfig.buildTime != resConfig.buildTime)
                {
                    Debug.Log("GameBootConfig覆盖写入:" + resConfig.buildTime);
                    FileUtils.CreateTextFile(persistentDataPath, jsonData);
                    return(resConfig);
                }
                else
                {
                    return(perConfig);
                }
            }
        }
        return(JsonUtils.FromJson <GameBootConfig>(jsonData));
    }
    public static void Save(GameBootConfig config)
    {
        string json = JsonUtils.ToJson(config);

        FileUtils.CreateTextFile(SavePathDir + ConfigFileName + ".txt", json);
    }