Exemplo n.º 1
0
 public void Init()
 {
     if (loadType == LoadType.LocalResource)
     {
         var versionAsset = Resources.Load <TextAsset>("DataVersion");
         var content      = versionAsset.text;
         gameDataVersion = JsonMapper.ToObject <GameDataVersion>(content);
         LoadAllDataSet();
     }
     else if (loadType == LoadType.URL) //URL 网络模式暂时只支持json
     {
         DownloadVersionFile();
     }
 }
Exemplo n.º 2
0
        private IEnumerator DownloadVersionFileCoroutine()
        {
            var url        = URLPath + "DataVersion.json";
            var webRequest = UnityWebRequest.Get(url);

            yield return(webRequest.SendWebRequest());

            //异常处理
            if (webRequest.isHttpError || webRequest.isNetworkError)
            {
                Debug.Log(webRequest.error);
            }
            else
            {
                var content = webRequest.downloadHandler.text;
                gameDataVersion = JsonMapper.ToObject <GameDataVersion>(content);
                LoadAllDataSet();
                Debug.Log(webRequest.downloadHandler.text);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 加载数据版本信息
        /// </summary>
        /// <returns></returns>
        public static GameDataVersion Load()
        {
            var versionAsset = Resources.Load <TextAsset>("DataVersion");

            if (versionAsset == null)
            {
                var version  = new GameDataVersion();
                var jsonStr  = JsonMapper.ToJson(version);
                var fullPath = Path.Combine(Config.RESOURCE_FOLDER_PATH, "DataVersion.json");
                File.WriteAllText(fullPath, jsonStr);
                return(version);
            }
            else
            {
                var content = versionAsset.text;
                var version = JsonMapper.ToObject <GameDataVersion>(content);
                Debug.Log("version:" + version.gameDataVersion);
                return(version);
            }
        }