예제 #1
0
        public static void LoadAsync(string abName, Action <AssetBundle> callback)
        {
            if (string.IsNullOrEmpty(abName))
            {
                Debug.LogError("abName or assetName is null!!!");
                if (callback != null)
                {
                    callback(null);
                }
                return;
            }

            Action <AssetLoadData> tCallBack = null;

            if (callback != null)
            {
                tCallBack = (data) =>
                {
                    callback(data.mAsset as AssetBundle);
                };
            }

            HAssetBundle res = Get <HAssetBundle>(abName, "", AssetType.eAB);

            res.StartLoad(false, false, false, tCallBack);
        }
예제 #2
0
 public void AddDepRef()
 {
     for (int i = 0; i < DepList.Count; i++)
     {
         if (mResMap.ContainsKey(DepList[i]))
         {
             HAssetBundle res = mResMap[DepList[i]] as HAssetBundle;
             res.OnAddRef();
         }
     }
 }
예제 #3
0
        public static AssetBundle Load(string abName)
        {
            if (string.IsNullOrEmpty(abName))
            {
                Debug.LogError("abName or assetName is null!!!");
                return(null);
            }

            HAssetBundle res = Get <HAssetBundle>(abName, "", AssetType.eAB);

            res.StartLoad(true, false, false, null);
            return(res.AssetData.mAsset as AssetBundle);
        }
예제 #4
0
 public override void Release()
 {
     //减少自身
     OnRelease();
     //减少依赖
     for (int i = 0; i < DepList.Count; i++)
     {
         if (mResMap.ContainsKey(DepList[i]))
         {
             HAssetBundle res = mResMap[DepList[i]] as HAssetBundle;
             res.OnRelease();
         }
     }
 }
예제 #5
0
        public void ReleaseAll()
        {
            List <HRes> resList = new List <HRes>();

            foreach (var item in HRes.mResMap)
            {
                resList.Add(item.Value);
            }

            //停止掉正在加载的AB
            ABRequest.StopAllRequest();
            //停止掉正在加载的AB中的资源
            AssetRequest.StopAllRequest();

            //释放AB资源
            for (int i = 0; i < resList.Count; i++)
            {
                resList[i].ReleaseAll();
            }

            HAssetBundle.ReleaseAssetBundleManifest();
        }
예제 #6
0
 //同步加载AB
 public AssetBundle LoadAB(string abName)
 {
     return(HAssetBundle.Load(abName));
 }
예제 #7
0
 //协程加载AB
 public AsyncRequest LoadABRequest(string abName)
 {
     return(HAssetBundle.LoadAsync(abName));
 }
예제 #8
0
 //异步加载AB
 public void LoadABAsync(string abName, Action <AssetBundle> callback)
 {
     HAssetBundle.LoadAsync(abName, callback);
 }