using System.Collections;
using System.Collections.Generic;
using System.IO;
using System;
using System.Net;
using UnityEngine;
using UnityEngine.UI;
using System.Text;
using System.Threading;
using System.Security.Cryptography;
using Application = UnityEngine.Application;
public class ResourceMgr
{
public const string NEEDDOWNLOADTITLE = “需要下载的资源:{0}/{1}”;
private const string HDMD5_NAME = “HDmd5.txt”;
private const string IMG_FILE_SUFFIX1 = “.png”;
private const string IMG_FILE_SUFFIX2 = “.jpg”;
private const string MODEL_FILE_SUFFIX1 = “.unity3d”;
private const string VEDIO_FILE_SUFFIX1 = “.mp4”;
private const string VEDIO_FILE_SUFFIX2 = “.avi”;
private const string IMGDIRECTORYNAME = "/sandimage/";
public const string MODELDIRECTORYNAME = "/Models/";
private const string VEDIOSDIRECTORYNAME = "/Video/";
private string streamingPath = "";
private static ResourceMgr _instance;
public static ResourceMgr instance
{
get
{
if (_instance == null)
{
_instance = new ResourceMgr();
_instance.streamingPath = Application.streamingAssetsPath;
}
return _instance;
}
}
//加载本地资源线程
private Thread loadImgThread = null;
/// <summary>
/// 处理多线程的sleep
/// </summary>
private AutoResetEvent loadImgThreadEvent = new AutoResetEvent(false);
private int errorCount = 0;
struct LoadImgData
{
public string fileName;
public Action<byte[]> action;
public LoadImgData(string _fileName, Action<byte[]> _action)
{
fileName = _fileName;
action = _action;
}
}
private List<LoadImgData> needLoadImgs = new List<LoadImgData>();
public void StopAllThread()
{
if (loadImgThread != null)
{
loadImgThread.Abort();
loadImgThread = null;
}
if (loadImgThreadEvent != null)
{
loadImgThreadEvent.Close();
loadImgThreadEvent = null;
}
}
private string GetAllPath(string fileName)
{
string path = "";
if (fileName.EndsWith(IMG_FILE_SUFFIX1) || fileName.End