using LitJson;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class DownloadData
{
///
/// 素材名称
///
public string name;
///
/// 素材类型
///
public int type;
///
/// 素材下载地址
///
public string downloadPath;
///
/// 本地保存地址
///
public string localSavePath;
///
/// 更新时间
///
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;
}
}