作为自己的笔记直接上代码咯!!!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestaddAssetBundle : MonoBehaviour {
// Use this for initialization
void Start () {
//从文件夹里通过依赖资源关系加载
AssetBundle bundle = AssetBundle.LoadFromFile("Assets/StreamingAssets/StreamingAssets");
AssetBundleManifest manifest = bundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");//加载依赖资源
string[] deps = manifest.GetDirectDependencies("cube.prefab.unity3d");
Debug.Log(deps.Length);
foreach (var item in deps)
{
AssetBundle.LoadFromFile("Assets/StreamingAssets/" + item);
Debug.Log(item);
}
AssetBundle ab = AssetBundle.LoadFromFile("Assets/StreamingAssets/cube.prefab.unity3d");
GameObject wallprefab = ab.LoadAsset<GameObject>("cube");
Instantiate(wallprefab);
}
// Update is called once per frame
void Update () {
}
}