示例#1
0
    /// <summary>
    /// 异步加载AssetBundle
    /// </summary>
    private IEnumerator AsyncLoad(AssetFile asset, Action <AssetFile> Actionfile)
    {
        if (manifestBundle == null)
        {
            Debug.LogError("manifest is null  wait!");
            yield return(null);
        }

        string filepath = AssetBundlePath.GetAssetBundlePath(asset.Name);
        AssetBundleCreateRequest req = AssetBundle.LoadFromFileAsync(filepath);

        while (!req.isDone)
        {
            asset.LoadProgress = req.progress * 100;
            yield return(null);
        }

        /// yield return asset.LoadAssetFileAsync(filepath);

        asset.LoadProgress = 100;
        asset.assetbundle  = req.assetBundle;

        if (Actionfile != null)
        {
            while (asset.IsReadyAll)
            {
                yield return(null);
            }

            Actionfile(asset);
        }

        yield return(null);
    }
示例#2
0
    /// <summary>
    /// 同步加载AssetBundle
    /// </summary>
    private void SyncLoad(AssetFile asset)
    {
        string filepath = AssetBundlePath.GetAssetBundlePath(asset.Name);

        asset.assetbundle = AssetBundle.LoadFromFile(filepath);

        if (asset.assetbundle == null)
        {
            Debug.LogError(" path no found file " + filepath);
        }

        asset.IsReady = true;
    }