コード例 #1
0
    public void LoadABManifest(bool isPermanent = false)
    {
        ResourceInfo bundle = GetResourceInfo(ABConfiger.ASSET_MANIFEST_NAME, ResourceType.RES_ASSETBUNDLE, isPermanent);
        string       path   = ABConfiger.GetABFilePath(ABConfiger.ASSET_MANIFEST_NAME);

        Debug.Log("load asset bundle url==" + path);

        if (path == string.Empty)
        {
            RemoveResourceInfo(ABConfiger.ASSET_MANIFEST_NAME);
            return;
        }

        AssetBundle assetBundle = AssetBundle.LoadFromFile(path);

        if (assetBundle == null)
        {
            RemoveResourceInfo(ABConfiger.ASSET_MANIFEST_NAME);

            Debug.LogError("Load Local Manifest error!");
            return;
        }

        assetBundleManifest = assetBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");
        bundle._assetObj    = assetBundle;
    }
コード例 #2
0
    private AssetBundle LoadAssetBundle(string name, string abPath)
    {
        string      path        = ABConfiger.GetABFilePath(abPath);
        AssetBundle assetbundle = AssetBundle.LoadFromFile(path);

        if (assetbundle == null)
        {
            return(null);
        }

        loadedAssetBundles.Add(name, new LoadedAssetBundle(name, assetbundle));
        return(assetbundle);
    }
コード例 #3
0
    private IEnumerator LoadAsyncAssetBundle(string name, string abPath, Action <UnityEngine.Object> load = null)
    {
        string path = ABConfiger.GetABFilePath(abPath);
        var    bundleLoadRequest = AssetBundle.LoadFromFileAsync(path);

        while (!bundleLoadRequest.isDone)
        {
            yield return(null);
        }

        var assetBundle = bundleLoadRequest.assetBundle;

        if (assetBundle == null)
        {
            loadedAssetBundles.Add(name, new LoadedAssetBundle(name, true, null));
            yield break;
        }

        loadedAssetBundles.Add(name, new LoadedAssetBundle(name, assetBundle));
        if (load != null)
        {
            load(assetBundle);
        }
    }