【热更】获取不同版本的files文件
parent
4549be3c7e
commit
2199025032
|
@ -441,10 +441,39 @@ namespace GameEditor.FrameTool {
|
||||||
responseStream.Close();
|
responseStream.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//重新下载外部.unity3d文件
|
||||||
|
private static void RegetExternalFile()
|
||||||
|
{
|
||||||
|
//获取下载文件链接
|
||||||
|
string url = m_VersionTxt.resUrl + "Android/files.unity3d";
|
||||||
|
//获取文件存放路径
|
||||||
|
fPath = pathInfo.Parent.FullName + @"\Temp";
|
||||||
|
if (File.Exists(fPath + @"\files.unity3d"))
|
||||||
|
{
|
||||||
|
File.Delete(fPath + @"\files.unity3d");
|
||||||
|
}
|
||||||
|
// 设置参数
|
||||||
|
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
||||||
|
//发送请求并获取相应回应数据
|
||||||
|
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
|
||||||
|
//直到request.GetResponse()程序才开始向目标网页发送Post请求
|
||||||
|
Stream responseStream = response.GetResponseStream();
|
||||||
|
//创建本地文件写入流
|
||||||
|
Stream stream = new FileStream(fPath + @"\files.unity3d", FileMode.Create, FileAccess.Write);
|
||||||
|
byte[] bArr = new byte[1024];
|
||||||
|
int size = responseStream.Read(bArr, 0, (int)bArr.Length);
|
||||||
|
while (size > 0)
|
||||||
|
{
|
||||||
|
stream.Write(bArr, 0, size);
|
||||||
|
size = responseStream.Read(bArr, 0, (int)bArr.Length);
|
||||||
|
}
|
||||||
|
stream.Close();
|
||||||
|
responseStream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
//遍历外部unity3d数据
|
//遍历外部unity3d数据
|
||||||
private static void GetExternalData()
|
private static void GetExternalData()
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log(fPath + "\\" + UpdateConfigs.FILES);
|
|
||||||
UnityEngine.AssetBundle bundle = UnityEngine.AssetBundle.LoadFromFile(fPath + "\\" + UpdateConfigs.FILES);
|
UnityEngine.AssetBundle bundle = UnityEngine.AssetBundle.LoadFromFile(fPath + "\\" + UpdateConfigs.FILES);
|
||||||
ResourceFiles files = bundle.LoadAsset<ResourceFiles>("game");
|
ResourceFiles files = bundle.LoadAsset<ResourceFiles>("game");
|
||||||
exDataList = files.files;
|
exDataList = files.files;
|
||||||
|
@ -468,9 +497,6 @@ namespace GameEditor.FrameTool {
|
||||||
{
|
{
|
||||||
inDataDic[inDataList[i].fileName] = inDataList[i];
|
inDataDic[inDataList[i].fileName] = inDataList[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
//inDataDic.Add(inDataList[i].fileName, inDataList[i]);
|
|
||||||
//UnityEngine.Debug.Log("fileName:" + inDataList[i].fileName + " CRC:" + inDataList[i].crc + " Size:" + inDataList[i].size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,26 +510,29 @@ namespace GameEditor.FrameTool {
|
||||||
Size = exDataList[i].size + Size;
|
Size = exDataList[i].size + Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UnityEngine.Debug.Log("Size:" + Size);
|
|
||||||
Size = Size / 1048576;
|
Size = Size / 1048576;
|
||||||
UnityEngine.Debug.Log("Size:" + Size);
|
UnityEngine.Debug.Log(Size + "M");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnGUI()
|
void OnGUI()
|
||||||
{
|
{
|
||||||
EditorGUILayout.BeginVertical();
|
EditorGUILayout.BeginVertical();
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
EditorGUILayout.LabelField("线上:");
|
EditorGUILayout.LabelField("线上位置:");
|
||||||
//m_VersionTxt.resUrl = EditorGUILayout.TextField(m_VersionTxt.resUrl);
|
m_VersionTxt.resUrl = EditorGUILayout.TextField(m_VersionTxt.resUrl);
|
||||||
EditorGUILayout.EndVertical();
|
EditorGUILayout.EndVertical();
|
||||||
|
if (GUILayout.Button("重新获取files", GUILayout.Height(40f)))
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.Log("URL:"+ m_VersionTxt.resUrl);
|
||||||
|
RegetExternalFile();
|
||||||
|
}
|
||||||
if (GUILayout.Button("对比大小", GUILayout.Height(40f)))
|
if (GUILayout.Button("对比大小", GUILayout.Height(40f)))
|
||||||
{
|
{
|
||||||
Size = 0;
|
Size = 0;
|
||||||
UnityEngine.Debug.Log("对比成功");
|
|
||||||
GetExternalData();
|
GetExternalData();
|
||||||
CompareData();
|
CompareData();
|
||||||
}
|
}
|
||||||
|
|
||||||
string resUrl = Size.ToString("0.00") + "M";
|
string resUrl = Size.ToString("0.00") + "M";
|
||||||
resUrl = EditorGUILayout.TextField(resUrl);
|
resUrl = EditorGUILayout.TextField(resUrl);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue