AB包所处的环境不同
public static IEnumerator GetAssetBundle(string path,Action<AssetBundle> callback)
{
StringBuilder filepath = new StringBuilder();
filepath.Append(Application.dataPath);
filepath.Append(path);
AssetBundleCreateRequest request = AssetBundle.LoadFromMemoryAsync(File.ReadAllBytes(filepath.ToString()));
yield return request;
callback(request.assetBundle);
}
string path = @"/AssetBundles/123.text";
Action<AssetBundle> callback=delegate(AssetBundle ab)
{
};
StartCoroutine(GetAssetBundle(path, callback));
Application.dataPath 所处的环境为Project_Data,将AB包文件夹放到里面就OK
这篇博客详细介绍了在Unity中如何使用AssetBundle.LoadFromMemoryAsync从内存中异步加载AssetBundle,以及如何配合Callback进行资源管理。通过示例代码展示了AssetBundle的加载过程,强调了Application.dataPath在Project_Data环境中的作用。
3882

被折叠的 条评论
为什么被折叠?



