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); } }
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); } }