12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using LitJson;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- public class DownloadData
- {
- /// <summary>
- /// 素材名称
- /// </summary>
- public string name;
- /// <summary>
- /// 素材类型
- /// </summary>
- public int type;
- /// <summary>
- /// 素材下载地址
- /// </summary>
- public string downloadPath;
- /// <summary>
- /// 本地保存地址
- /// </summary>
- public string localSavePath;
- /// <summary>
- /// 更新时间
- /// </summary>
- public int updateTime;
- public DownloadData()
- {
- name = "";
- type = 0;
- downloadPath = "";
- localSavePath = "";
- updateTime = 0;
- }
- public DownloadData(MaterialObjValue mat)
- {
- type = int.Parse(mat.type);
- downloadPath = string.IsNullOrWhiteSpace(mat.DownloadPath) ? "" : mat.DownloadPath;
- string filename = Path.GetFileName(downloadPath);
- name = string.IsNullOrWhiteSpace(mat.name) ? filename : mat.name;
- if (string.IsNullOrWhiteSpace(mat.localSavePath))
- {
- //localSavePath = FileManager.CalFilePath(Path.Combine(DownloadManager.Instance.LocaDataPath, filename));
- switch (type)
- {
- case 1: //image
- localSavePath = DownloadManager.Instance.LocaDataPath + "/Image/" + filename;
- break;
- case 2: //video
- localSavePath = DownloadManager.Instance.LocaDataPath + "/video/" + filename;
- break;
- case 3: //model
- localSavePath = DownloadManager.Instance.LocaDataPath + "/Model/" + filename;
- name = filename;
- break;
- default:
- break;
- }
- //Debug.Log(localSavePath);
- }
- else
- {
- localSavePath = mat.localSavePath;
- }
- }
- public DownloadData(JsonData json)
- {
- name = (string)json["name"];
- type = (int)json["type"];
- downloadPath = (string)json["downloadPath"];
- localSavePath = (string)json["localSavePath"];
- updateTime = (int)json["updateTime"];
- }
- public JsonData ToJsonData()
- {
- JsonData data = new JsonData();
- data["name"] = name;
- data["type"] = type;
- data["downloadPath"] = downloadPath;
- data["localSavePath"] = localSavePath;
- data["updateTime"] = updateTime;
- return data;
- }
- }
|