/// <summary> /// /// </summary> /// <returns>The asset.</returns> public T GetAsset <T>(string assetbundlename, string assetname) where T : UnityEngine.Object { var lab = cache.GetBundleCache(assetbundlename); if (lab == null) { Debug.LogError("not found which ab named:" + assetbundlename); return(null); } var obj = lab.GetAsset(assetname); if (obj != null) { return(obj as T); } var t = lab.Bundle.LoadAsset <T>(assetname); //同步加载之后清除loading并设置缓存 if (t != null) { lab.RemoveLoading(assetname); lab.SetAssetCache(assetname, t); } return(t); }
/// <summary> /// 检查是否已经从网络下载 /// </summary> protected WWW IsLoadAssetBundleAtInternal(string assetBundleName) { //已经存在了呀 LOAssetBundle bundle = LOAssetCache.GetBundleCache(assetBundleName); if (bundle != null) { //保留一次 bundle.Retain(); return(null); } //如果WWW缓存策略中包含有对应的关键字,则返回null if (LOAssetCache.InWWWCache(assetBundleName)) { return(null); } //创建下载链接 WWW www = new WWW(LOAssetManager.URI + assetBundleName); //加入缓存策略 LOAssetCache.SetWWWCache(assetBundleName, www); return(www); }
/// <summary> /// /// </summary> /// <returns>The asset.</returns> public T GetAsset <T>(string assetbundlename, string assetname) where T : UnityEngine.Object { LOAssetBundle lab = LOAssetCache.GetBundleCache(assetbundlename); if (lab == null) { return(null); } else { return(lab.m_AssetBundle.LoadAsset <T>(assetname)); } }