コード例 #1
0
 /// <summary>
 /// 队列加载
 /// </summary>
 /// <param name="pathList"></param>
 /// <param name="listId"></param>
 /// <param name="loaderListComplete"></param>
 /// <param name="loaderProgress"></param>
 /// <param name="loaderError"></param>
 /// <param name="loaderListProgress"></param>
 /// <param name="loaderFileComplete"></param>
 /// <param name="param"></param>
 public static void LoadList <T>(List <StResPath> pathList,
                                 string listId,
                                 ResLoaderManager.DelegateListLoaded loaderListComplete,
                                 ResLoaderManager.DelegateLoaderProgress loaderProgress         = null,
                                 ResLoaderManager.DelegateLoaderError loaderError               = null,
                                 ResLoaderManager.DelageteLoaderListProgress loaderListProgress = null,
                                 ResLoaderManager.DelegateFileLoaded loaderFileComplete         = null,
                                 object param = null) where T : UnityEngine.Object
 {
     if (!isByWWWLoad)
     {
         if (!_listStateDict.ContainsKey(listId))
         {
             _listStateDict[listId] = pathList.Count;
             int len = pathList.Count;
             for (int i = 0; i < len; i++)
             {
                 LoadFromLocalRes <T>(pathList[i], listId, loaderListComplete, loaderFileComplete, loaderError, loaderListProgress, param);
             }
         }
         else
         {
             Log.info("队列正在加载中,请检查 listID: " + listId);
             return;
         }
     }
     else
     {
         ResLoaderManager.instance.Loader(pathList, listId, loaderListComplete, loaderProgress, loaderError, loaderListProgress, loaderFileComplete, param);
     }
 }
コード例 #2
0
    /// <summary>
    /// 本地加载,支持  texture,audio,txt,types,prefab
    /// </summary>
    /// <param name="resPath">路径需包含后缀名,本地载入会进行截取</param>
    /// <param name="loaderFileComplete"></param>
    /// <param name="loaderError"></param>
    /// <param name="param"></param>
    private static void LoadFromLocalRes <T>(
        StResPath resPath,
        string id,
        ResLoaderManager.DelegateListLoaded loaderListComplete,
        ResLoaderManager.DelegateFileLoaded loaderFileComplete,
        ResLoaderManager.DelegateLoaderError loaderError,
        ResLoaderManager.DelageteLoaderListProgress loaderListProgress = null,
        object param = null) where T : UnityEngine.Object
    {
        //完整路径
        string fullPath = SystemConfig.localPlatformResPath + resPath.path + ".unity3d";

        if (ResDataManager.instance.HasEditorRes(fullPath))
        {
            if (loaderFileComplete != null)
            {
                loaderFileComplete(fullPath, param);
            }
        }
        else
        {
            VOLocalLoadNode node = new VOLocalLoadNode();
            node.resPath            = resPath;
            node.id                 = id;
            node.loaderListComplete = loaderListComplete;
            node.loaderFileComplete = loaderFileComplete;
            node.loaderError        = loaderError;
            node.loaderListProgress = loaderListProgress;
            node.param              = param;
            node.type               = typeof(T).ToString();
            StartLoad(node);
        }
    }
コード例 #3
0
 /// <summary>
 /// 销毁
 /// </summary>
 public void Dispose()
 {
     this.pathList.Clear();
     this.param = null;
     this.OnLoaderListComplete = null;
     this.OnLoaderFileError    = null;
     this.OnLoaderListProgress = null;
     this.OnLoaderFileProgress = null;
     this.OnLoaderFileComplete = null;
 }
コード例 #4
0
    /// <summary>
    /// 单个资源加载
    /// </summary>
    /// <param name="resPath"></param>
    /// <param name="loaderComplete"></param>
    /// <param name="loaderProgress"></param>
    /// <param name="loaderError"></param>
    /// <param name="param"></param>
    public void Loader(
        StResPath resPath,
        ResLoaderManager.DelegateFileLoaded loaderFileComplete,
        ResLoaderManager.DelegateLoaderProgress loaderProgress = null,
        ResLoaderManager.DelegateLoaderError loaderError       = null,
        object param = null)

    {
        List <StResPath> pathList = new List <StResPath>();

        pathList.Add(resPath);
        Loader(pathList, resPath.path, null, loaderProgress, loaderError, null, loaderFileComplete, param);
    }
コード例 #5
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="orderName"></param>
 /// <param name="pathList"></param>
 /// <param name="loaderProgress"></param>
 /// <param name="loaderComplete"></param>
 /// <param name="loaderError"></param>
 /// <param name="loaderListProgress"></param>
 /// <param name="loaderFileComplete"></param>
 /// <param name="param"></param>
 public ResLoaderOrder(
     string orderName,
     IList <StResPath> pathList,
     ResLoaderManager.DelegateLoaderProgress loaderProgress,
     ResLoaderManager.DelegateListLoaded loaderListComplete,
     ResLoaderManager.DelegateLoaderError loaderError,
     ResLoaderManager.DelageteLoaderListProgress loaderListProgress = null,
     ResLoaderManager.DelegateFileLoaded loaderFileComplete         = null,
     object param = null)
 {
     this.Id       = orderName;
     this.pathList = new List <StResPath>();
     this.ClearRepeatItem(pathList);
     this.total = this.pathList.Count;
     this.param = param;
     this.AttachEvent(loaderListComplete, loaderProgress, loaderError, loaderListProgress, loaderFileComplete);
 }
コード例 #6
0
 /// <summary>
 /// 单个文件加载 - 图片
 /// </summary>
 /// <param name="path"></param>
 /// <param name="loaderFileComplete"></param>
 /// <param name="loaderProgress"></param>
 /// <param name="loaderError"></param>
 /// <param name="param"></param>
 public static void LoadTexture(
     string path,
     ResLoaderManager.DelegateFileLoaded loaderFileComplete,
     ResLoaderManager.DelegateLoaderProgress loaderProgress = null,
     ResLoaderManager.DelegateLoaderError loaderError       = null,
     object param = null)
 {
     path = FormatLocalPath(path);
     if (!isByWWWLoad)
     {
         LoadFromLocalRes <Texture>(new StResPath(path), path, null, loaderFileComplete, loaderError, null, param);
     }
     else
     {
         path = SystemConfig.localPlatformResPath + path + ".unity3d";
         ResLoaderManager.instance.Loader(new StResPath(path), loaderFileComplete, loaderProgress, loaderError, param);
     }
 }
コード例 #7
0
 /// <summary>
 /// 单个文件加载
 /// </summary>
 /// <param name="resPath"></param>
 /// <param name="loaderFileComplete"></param>
 /// <param name="loaderProgress"></param>
 /// <param name="loaderError"></param>
 /// <param name="param"></param>
 public static void Load <T>(
     StResPath resPath,
     ResLoaderManager.DelegateFileLoaded loaderFileComplete,
     ResLoaderManager.DelegateLoaderProgress loaderProgress = null,
     ResLoaderManager.DelegateLoaderError loaderError       = null,
     object param = null) where T : UnityEngine.Object
 {
     resPath.path = FormatLocalPath(resPath.path);
     if (!isByWWWLoad)
     {
         LoadFromLocalRes <T>(resPath, resPath.path, null, loaderFileComplete, loaderError, null, param);
     }
     else
     {
         resPath.path = SystemConfig.localPlatformResPath + resPath.path + ".unity3d";
         ResLoaderManager.instance.Loader(resPath, loaderFileComplete, loaderProgress, loaderError, param);
     }
 }
コード例 #8
0
 /// <summary>
 /// 移除事件
 /// </summary>
 /// <param name="loaderComplete"></param>
 /// <param name="loaderProgress"></param>
 /// <param name="loaderError"></param>
 /// <param name="loaderListProgress"></param>
 /// <param name="loaderFileComplete"></param>
 public void RemoveEvent(ResLoaderManager.DelegateListLoaded loaderComplete, ResLoaderManager.DelegateLoaderProgress loaderProgress, ResLoaderManager.DelegateLoaderError loaderError, ResLoaderManager.DelageteLoaderListProgress loaderListProgress = null, ResLoaderManager.DelegateFileLoaded loaderFileComplete = null)
 {
     if (loaderProgress != null)
     {
         this.OnLoaderFileProgress -= loaderProgress;
     }
     if (loaderComplete != null)
     {
         this.OnLoaderListComplete -= loaderComplete;
     }
     if (loaderError != null)
     {
         this.OnLoaderFileError -= loaderError;
     }
     if (loaderListProgress != null)
     {
         this.OnLoaderListProgress -= loaderListProgress;
     }
     if (loaderFileComplete != null)
     {
         this.OnLoaderFileComplete -= loaderFileComplete;
     }
 }
コード例 #9
0
    /// <summary>
    /// 队列加载
    /// </summary>
    /// <param name="pathList"></param>
    /// <param name="id"></param>
    /// <param name="loaderListComplete">队列加载完成</param>
    /// <param name="loaderProgress">单个文件进度</param>
    /// <param name="loaderError">单个文件错误</param>
    /// <param name="loaderListProgress">队列进度</param>
    /// <param name="loaderFileComplete">单个加载完成</param>
    /// <param name="param"></param>
    public void Loader(
        List <StResPath> pathList,
        string id,
        ResLoaderManager.DelegateListLoaded loaderListComplete,
        ResLoaderManager.DelegateLoaderProgress loaderProgress         = null,
        ResLoaderManager.DelegateLoaderError loaderError               = null,
        ResLoaderManager.DelageteLoaderListProgress loaderListProgress = null,
        ResLoaderManager.DelegateFileLoaded loaderFileComplete         = null,
        object param = null)

    {
        if (this._orderList == null)
        {
            this._orderList = new List <ResLoaderOrder>();
        }
        //去重处理
        ResLoaderOrder resLoaderOrder = this.GetWwwLoaderOrderByOrderName(id);

        if (resLoaderOrder != null)
        {
            if (LoadThreadManager.showDebug)
            {
                Log.info("[Warn! 与当前加载中的list名相同,请确保唯一性!] id: " + id);
            }
            //如果已有相同的资源在加载,添加新回调
            resLoaderOrder.AttachEvent(loaderListComplete, loaderProgress, loaderError, loaderListProgress, loaderFileComplete);
            return;
        }


        //添加到订阅队列中
        IList <StResPath> pList = new List <StResPath>(pathList.ToArray());

        resLoaderOrder = new ResLoaderOrder(id, pList, loaderProgress, loaderListComplete, loaderError, loaderListProgress, loaderFileComplete, param);
        this._orderList.Add(resLoaderOrder);

        //遍历订阅文件,开始推入线程加载
        int len = resLoaderOrder.pathList.Count;

        if (len == 0)
        {
            this.LoaderOperater(id);
            return;
        }

        for (int i = 0; i < len; i++)
        {
            StResPath stPath = resLoaderOrder.pathList[i];
            //检查是否在缓存对象中,是否已经加载过
            bool existsStatus = ResDataManager.instance.ExistWWWData(stPath.path);
            if (!existsStatus)
            {//不存在,加载并缓存
                ResLoader resLoader = new ResLoader(resLoaderOrder.Id);
                resLoader.Loader(stPath, OnProgressHandler, OnCompleteHandler, OnErrorHandler);
            }
            else
            {//资源已存在,无需加载
                if (LoadThreadManager.showDebug)
                {
                    Log.info("加载 " + stPath.path + " 资源已存在 !");
                }
                this.LoaderOperater(id, stPath);
            }
        }
    }