unity 《专题系列》资源打包 Asset Bundles
第四节 Asset Bundles 加载manifest
一、什么是manifest
1、manifest 文件就是记录对应资源的一些信息,比如名称,依赖关系,CRC等,可以用文本形式打开;
2、具体manifest文件打开样本,如下图
二、mainfest 具体使用方法
1、代码及运行结果,如下图
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.Networking;
public class LoadAssetBundle : MonoBehaviour {
// Use this for initialization
void Start () {
//2.2 LoadFromFile 方法加载
//AssetBundle的存放路径
string path = "Assets/AssetBundles/sphereab.unityab";
AssetBundle ab = AssetBundle.LoadFromFile(path);
//取得所需要的资源
GameObject go = ab.LoadAsset<GameObject>("Sphere");
//加载生成到场景中
Instantiate(go);
//加载mainfest文件
AssetBundle manifestAB = AssetBundle.LoadFromFile("Assets/AssetBundles/AssetBundles");
AssetBundleManifest manifest = manifestAB.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
foreach (string name in manifest.GetAllAssetBundles()) {
//打印相关资源的信息
print(name);
}
}
}