This commit is contained in:
lishuo committed 2022-05-13 09:28:58 +08:00
1 parent 509c309252
commit 11b131b24a
60 files changed
+2505 -632

No files matched your search

+2
View File
@@ -14,6 +14,8 @@ public class Loom : MonoBehaviour
public static int maxThreads = 8;
static int numThreads;
public static Dictionary<string, float> DownLoadTaskList = new Dictionary<string, float>();
private static Loom _current;
public static Loom Current
{
+13 -14
View File
@@ -9,6 +9,7 @@ using System.IO;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
@@ -465,19 +466,14 @@ namespace Assets.Scripts
//下载video
public static IEnumerator DownloadVideo(string fileName,string url, UnityAction<float, UnityWebRequest> onProcessing = null, UnityAction<string> onCompleted = null)
{
string local = "";
string error = "";
var path = PFConstants.VideoFolder;
var filepath = path + $"/{fileName}";
//根据id读取本地文件
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
var filepath= path+$"/{fileName}";
if (File.Exists(filepath))
{
local = filepath;
}
//本地文件读取不到读取网络文件
else
{
@@ -493,21 +489,24 @@ namespace Assets.Scripts
}
if (request.isNetworkError || request.isHttpError)
{
error = request.error;
Debug.Log(request.error);
}
else
{
var fs = File.Create(filepath);
fs.Write(request.downloadHandler.data, 0, request.downloadHandler.data.Length);
fs.Close();
fs.Dispose();
fs = null;
local = filepath;
Task.Run(() =>
{
var fs = File.Create(filepath);
fs.Write(request.downloadHandler.data, 0, request.downloadHandler.data.Length);
fs.Close();
fs.Dispose();
fs = null;
});
}
}
if (onCompleted != null)
{
onCompleted.Invoke(local);
onCompleted.Invoke(error);
}
}
static IEnumerator DownloadImage(MaskableGraphic img,string MediaUrl, Action<Texture> action = null,UnityAction<byte[]> callback = null)