Exemplo n.º 1
0
    void Start()
    {
        m_assetPath = "file://" + Application.dataPath + "/StreamingAssets/" + PlatformManifest.GetMainManifest(Application.platform) + "/";

        time = Time.time;
        StartCoroutine(DownloadAssetBundleManifest((Manifest) =>
        {
            StartCoroutine(LoadDependenceAsset(fileName, Manifest, (fileName2, Manifest2, bundle) =>
            {
                StartCoroutine(LoadAssetByName(fileName2, Manifest2, bundle));
            }));
        }));
    }
Exemplo n.º 2
0
    /// <summary>
    /// 获取总的AssetBundleManifest文件
    /// </summary>
    /// <param name="finish">完后加载后调用的委托</param>
    /// <returns></returns>
    public IEnumerator DownloadAssetBundleManifest(Action <AssetBundleManifest> finish = null)
    {
        WWW www = WWW.LoadFromCacheOrDownload(m_assetPath + PlatformManifest.GetMainManifest(Application.platform), version);

        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.LogError(www.error);
        }
        else
        {
            AssetBundle bundle = www.assetBundle;                                                         //获取AssetBundle

            AssetBundleManifest manifest = bundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); //获取总的AssetBundleManifest
            bundle.Unload(false);
            Debug.Log(manifest);
            if (finish != null)
            {
                finish.Invoke(manifest);
            }
        }
    }