예제 #1
0
        // 检测是否已经创建了WWW,没有就创建WWW
        // Where we actuall call WWW to download the assetBundle.
        bool LoadAssetBundleInternal(AFileInfo fileInfo)
        {
            string assetBundleName = fileInfo.assetBundleName;
            // Already loaded.
            AssetBundleInfo bundle = null;

            m_LoadedAssetBundles.TryGetValue(assetBundleName, out bundle);
            if (bundle != null)
            {
                bundle.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      = assetManager.GetRealURL(fileInfo.path);

            download = WWW.LoadFromCacheOrDownload(url, Hash128.Parse(fileInfo.md5), 0);
            m_DownloadingWWWs.Add(assetBundleName, download);

            return(false);
        }
    static int GetRealURL(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        CC.Runtime.AssetManager obj = (CC.Runtime.AssetManager)LuaScriptMgr.GetUnityObjectSelf(L, 1, "CC.Runtime.AssetManager");
        string arg0 = LuaScriptMgr.GetLuaString(L, 2);
        string o    = obj.GetRealURL(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
예제 #3
0
        IEnumerator OnLoadManifest()
        {
            WWW www = new WWW(assetManager.GetRealURL(manifestPath));

            yield return(www);

            if (!string.IsNullOrEmpty(www.error))
            {
                Debug.Log(string.Format("<color=red>[OnLoadManifest] manifest路径不对,或文件不存在 Error={0},  manifestPath={1}, manifestName={2}</color>", www.error, manifestPath, manifestName));
                yield break;
            }

            AssetBundle assetBundle = www.assetBundle;

            AssetBundleRequest assetBundleRequest = assetBundle.LoadAssetAsync <AssetBundleManifest>("AssetBundleManifest");

            yield return(assetBundleRequest);

            m_AssetBundleManifest = (AssetBundleManifest)assetBundleRequest.asset;

            assetManager.OnLoadManifest(this);
        }