Tekkaman

导航

 

Loading AssetBundle Manifests

  AssetBundle Manifest 可以用于获取dependency。

AssetBundle assetBundle = AssetBundle.LoadFromFile(manifestFilePath);
AssetBundleManifest manifest = assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");

  使用 GetAllDependencies 方法加载所有依赖

AssetBundle assetBundle = AssetBundle.LoadFromFile(manifestFilePath);
AssetBundleManifest manifest = assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
string[] dependencies = manifest.GetAllDependencies("assetBundle"); //Pass the name of the bundle you want the dependencies for.
foreach(string dependency in dependencies)
{
    AssetBundle.LoadFromFile(Path.Combine(assetBundlePath, dependency));
}

unload

  AssetBundle.Unload(bool); and if you should pass true or false into the function call. Unload is a non-static function that will unload your AssetBundle. This API unloads the header information of the AssetBundle being called. The argument indicates whether to also unload all Objects instantiated from this AssetBundle.

  If you were to use AssetBundle.Unload(true) the objects that you loaded from the AssetBundle, even if they’re being currently used in the active scene. This is what can cause textures to go missing, as we mentioned earlier.

  Let’s assume Material M is loaded from AssetBundle AB as shown below.

  If AB.Unload(true) is called. Any instance of M in the active scene will also be unload and destroyed.

  If you were instead to call AB.Unload(false) it would break the chain of the current instances of M and AB.

 

posted on 2017-10-01 07:13  Tekkaman  阅读(343)  评论(0编辑  收藏  举报