Exemple #1
0
 public void Reset()
 {
     m_DealFinish       = null;
     m_DealResObjFinish = null;
     m_Params           = null;
     m_ResObj           = null;
 }
Exemple #2
0
        /// <summary>
        /// 异步资源加载,针对ObjectManager的,(需要实例化对象的异步加载)
        /// </summary>
        public void AsyncLoadResource(string path, ResourceObj resObj, OnAsyncResObjFinish dealFinish, LoadResPriority priority, uint crc = 0, params object[] paramList)
        {
            AssetBundleInfo abInfo = GetCacheAssetBundleInfo(resObj.m_Crc);

            if (abInfo != null)
            {
                resObj.m_AssetBundleInfo = abInfo;
                if (dealFinish != null)
                {
                    dealFinish(path, resObj, paramList);
                }

                return;
            }
            //判断是否在加载中
            AsyncLoadResUnit unit = null;

            //没有找到这个异步加载单位,或者这个异步加载单位是空
            if (!m_LoadingAssetDic.TryGetValue(resObj.m_Crc, out unit) || unit == null)
            {
                unit            = m_AsyncLoadResParamPool.Spawn(true);
                unit.m_Crc      = resObj.m_Crc;
                unit.m_Path     = path;
                unit.m_Priority = priority;

                m_LoadingAssetDic.Add(resObj.m_Crc, unit);   //添加到正在异步加载的资源dic中

                m_loadingAssetList[(int)priority].Add(unit); //按照加载优先级,添加到对应的正在异步加载的资源列表中
            }

            //往回调列表里面添加回调
            AsynCallBack callBack = m_AsynCallBackPool.Spawn(true);

            callBack.m_Params = paramList;

            callBack.m_DealResObjFinish = dealFinish;
            callBack.m_ResObj           = resObj;
            //往这个异步加载单位的回调列表中添加一个回调
            //可能多个地方加载同一份资源,这样做只加载一次资源,
            //加载完了后,根据回调列表依次返回这份资源
            unit.m_CallBackList.Add(callBack);
        }