public T LoadBundleAssets <T>(string bundleName, string assetName) where T : Object { string bundleResName = bundleName; if (Path.GetExtension(bundleName) != ".data") { bundleResName = bundleName + ".data"; } bundleResName = bundleResName.ToLower(); BundleLoaderSharedObject blso; if (!mBundleLoaderSharedObjectDict.TryGetValue(bundleResName, out blso)) { blso = new BundleLoaderSharedObject(); if (blso.Load(bundleResName, false)) { mBundleLoaderSharedObjectDict.Add(bundleResName, blso); } else { return(null); } } if (blso != null) { return(blso.AssetObject(assetName) as T); } return(null); }
//同步加载资源 public UnityEngine.Object LoadAssetBundle(string bundleName, out UnityEngine.Object obj, bool loadAsset = true) { if (mAssetBundleManifest == null || string.IsNullOrEmpty(bundleName)) { obj = null; return(obj); } string bundleResName = bundleName; if (Path.GetExtension(bundleName) != ".data") { bundleResName = bundleName + ".data"; } bundleResName = bundleResName.ToLower(); //check dependant LoadAssetBundleDependencies(bundleResName); BundleLoaderSharedObject blso; if (!mBundleLoaderSharedObjectDict.TryGetValue(bundleResName, out blso)) { blso = new BundleLoaderSharedObject(); if (blso.Load(bundleResName, loadAsset)) { mBundleLoaderSharedObjectDict.Add(bundleResName, blso); } else { obj = null; return(obj); } } if (blso != null) { obj = blso.AssetObject(loadAsset); return(obj); } obj = null; return(obj); }