Exemplo n.º 1
0
 //释放从Bundle中Load的所有资源
 public void ReleseBundleAsset(string bundleName)
 {
     if (loadedAssetMDic.ContainsKey(bundleName))
     {
         BundleAssetM baM = loadedAssetMDic[bundleName];
         baM.ReleseAllAsset();
         Resources.UnloadUnusedAssets();
     }
 }
Exemplo n.º 2
0
 // 释放单个从Bundle中Load的资源
 public void ReleseLoadedAsset(string bundleName, string resName)
 {
     if (loadedAssetMDic.ContainsKey(bundleName))
     {
         BundleAssetM baM = loadedAssetMDic[bundleName];
         Debug.Log(" Relese Res  resName =" + resName);
         baM.ReleseAsset(resName);
     }
     else
     {
         Debug.Log("Dont Have BundleAsset Manager   bundleName =" + bundleName);
     }
 }
Exemplo n.º 3
0
 public Object GetSingleRes(string bundleName, string resName)
 {
     //是否缓存了物体
     if (loadedAssetMDic.ContainsKey(bundleName))
     {
         List <Object> tmpList = loadedAssetMDic[bundleName].GetLoadedAssets(resName);
         Debug.Log("已缓存Asset  = " + tmpList[0].name);
         if (tmpList != null)
         {
             return(tmpList[0]);
         }
     }
     //是否加载过Bundle
     if (loadHelperDic.ContainsKey(bundleName))
     {
         ABRelativeM abM = loadHelperDic[bundleName];
         Debug.Log("从已缓存bundle中加载 bundleName = " + bundleName + " Asset =" + resName);
         Object tmpObj   = abM.GetSingleRes(resName);
         Asset  assetObj = new Asset(tmpObj);
         //如果当前已经存在Bundle的BundleAssetM
         if (loadedAssetMDic.ContainsKey(bundleName))
         {
             BundleAssetM assetM = loadedAssetMDic[bundleName];
             assetM.AddAsset(resName, assetObj);
         }
         //如果当前不存在该Bundle的BundleAssetM
         else
         {
             BundleAssetM assetM = new BundleAssetM(resName, assetObj);
             loadedAssetMDic.Add(bundleName, assetM);
         }
         return(tmpObj);
     }
     else
     {
         Debug.Log("Dont Load the Bundle    bundleName = " + bundleName);
         return(null);
     }
 }
Exemplo n.º 4
0
 public Object[] GetMultRes(string bundleName, string resName)
 {
     //是否缓存了物体
     if (loadedAssetMDic.ContainsKey(bundleName))
     {
         List <Object> tmpList = loadedAssetMDic[bundleName].GetLoadedAssets(resName);
         if (tmpList != null)
         {
             return(tmpList.ToArray());
         }
     }
     //是否加载过Bundle
     if (loadHelperDic.ContainsKey(bundleName))
     {
         ABRelativeM abM      = loadHelperDic[bundleName];
         Object[]    tmpObj   = abM.GetMultRes(resName);
         Asset       assetObj = new Asset(tmpObj);
         //如果当前已经缓存过 该 bundleName 的Res
         if (loadedAssetMDic.ContainsKey(bundleName))
         {
             BundleAssetM assetM = loadedAssetMDic[bundleName];
             assetM.AddAsset(resName, assetObj);
         }
         //当前未缓存过该bundleName的包
         else
         {
             BundleAssetM assetM = new BundleAssetM(resName, assetObj);
             loadedAssetMDic.Add(bundleName, assetM);
         }
         return(tmpObj);
     }
     else
     {
         Debug.Log("Dont Load the Bundle    bundleName = " + bundleName);
         return(null);
     }
 }