static int GetLoadedAssetBundle(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); string arg0 = LuaScriptMgr.GetLuaString(L, 1); string arg1 = null; SimpleFramework.Manager.AssetBundleInfo o = SimpleFramework.Manager.ResourceManager.GetLoadedAssetBundle(arg0, out arg1); LuaScriptMgr.PushObject(L, o); LuaScriptMgr.Push(L, arg1); return(2); }
// Returns true if more Update calls are required. public override bool Update() { if (m_Request != null) { return(false); } AssetBundleInfo bundle = ResourceManager.GetLoadedAssetBundle(m_AssetBundleName, out m_DownloadingError); if (bundle != null) { m_Request = bundle.m_AssetBundle.LoadAssetAsync(m_AssetName, m_Type); return(false); } else { return(true); } }
// Get loaded AssetBundle, only return vaild object when all the dependencies are downloaded successfully. static public AssetBundleInfo GetLoadedAssetBundle(string assetBundleName, out string error) { if (m_DownloadingErrors.TryGetValue(assetBundleName, out error)) { return(null); } AssetBundleInfo bundle = null; m_LoadedAssetBundles.TryGetValue(assetBundleName, out bundle); if (bundle == null) { return(null); } // No dependencies are recorded, only the bundle itself is required. string[] dependencies = null; if (!m_Dependencies.TryGetValue(assetBundleName, out dependencies)) { return(bundle); } // Make sure all dependencies are loaded foreach (var dependency in dependencies) { if (m_DownloadingErrors.TryGetValue(assetBundleName, out error)) { return(bundle); } // Wait all the dependent assetBundles being loaded. AssetBundleInfo dependentBundle; m_LoadedAssetBundles.TryGetValue(dependency, out dependentBundle); if (dependentBundle == null) { return(null); } } return(bundle); }
// Where we actuall call WWW to download the assetBundle. static protected bool LoadAssetBundleInternal(string assetBundleName, bool isLoadingAssetBundleManifest) { // Already loaded. AssetBundleInfo bundle = null; m_LoadedAssetBundles.TryGetValue(assetBundleName, out bundle); if (bundle != null) { bundle.m_ReferencedCount++; return(true); } // @TODO: Do we need to consider the referenced count of WWWs? // In the demo, we never have duplicate WWWs as we wait LoadAssetAsync()/LoadLevelAsync() to be finished before calling another LoadAssetAsync()/LoadLevelAsync(). // But in the real case, users can call LoadAssetAsync()/LoadLevelAsync() several times then wait them to be finished which might have duplicate WWWs. if (m_DownloadingWWWs.ContainsKey(assetBundleName)) { return(true); } WWW download = null; string url = m_BaseDownloadingURL + assetBundleName; // For manifest assetbundle, always download it as we don't have hash for it. if (isLoadingAssetBundleManifest) { download = new WWW(url); } else { download = WWW.LoadFromCacheOrDownload(url, m_AssetBundleManifest.GetAssetBundleHash(assetBundleName), 0); } m_DownloadingWWWs.Add(assetBundleName, download); return(false); }