Reputation: 2417
Here my code:
AssetBundle ab = AssetBundle.LoadFromFile(Application.dataPath + "/uia.manifest");//get null here
AssetBundleManifest manifest = (AssetBundleManifest)ab.LoadAsset("AssetBundleManifest");
Upvotes: 1
Views: 3775
Reputation: 66
The file you have to load in AssetBundle.LoadFromFile
is the file Assets
, which is a file that is stored in the same folder as your AssetBundle uia
. This Assets
file gets the same name as the folder is stored in, in this case Assets
. Your code would be like this:
AssetBundle ab = AssetBundle.LoadFromFile(Application.dataPath + "/Assets");
AssetBundleManifest manifest = (AssetBundleManifest)ab.LoadAsset("AssetBundleManifest");
Upvotes: 1
Reputation: 90813
Have a look at Using AssetBundles Natively in particular the section Loading AssetBundle Manifests where it states
Loading AssetBundle manifests can be incredibly useful. Especially when dealing with AssetBundle dependencies.
To get a useable AssetBundleManifest object, you’ll need to load that additional AssetBundle (the one that’s named the same thing as the folder it’s in) and load an object of type
AssetBundleManifest
from it.Loading the manifest itself is done exactly the same as any other Asset from an AssetBundle:
AssetBundle assetBundle = AssetBundle.LoadFromFile(manifestFilePath); AssetBundleManifest manifest = assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
Though it is not well documented to be honest, in the examples around AssetBundles.LoadFromFile
you can see that they do not load the "Example.manifest"
as AssetBundle
but rather only "Example"
without a suffix!
So in your case it seems to be placed in Assets/uia
and you would load this archive as AssetBundle, not a specific file in it.
AssetBundle assetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.dataPath, "uia"));
AssetBundleManifest manifest = assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
Also see the AssetBundle
Manual
“AssetBundle” can refer to two different, but related things.
First is the actual file on disk. This is called the AssetBundle archive. The AssetBundle archive is a container, like a folder, that holds additional files inside it.
→ the manifest is a part of this archive and can only be loaded by loading the AssetBundle and then grab the manifest from it!
Upvotes: 1