//AssetBUndle中获取模型, 此种方法支持中文
static public GameObject GetModelObjectFromAssetBUndle(string path)
{
FileStream AssetIO = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
byte[] assetbytes = new byte[AssetIO.Length];
AssetIO.Read(assetbytes, 0, (int)AssetIO.Length);
AssetIO.Close();
AssetBundle bundle = AssetBundle.LoadFromMemory(assetbytes);//从内存中创建资源
GameObject go = null;
var ast = bundle.LoadAllAssets();
foreach (var VARIABLE in ast)
{
if (VARIABLE as GameObject)
{
if (!go)
{
go = VARIABLE as GameObject;
}
}
}
bundle.Unload(false);
return go;
}
加载AssetBundle文件
最新推荐文章于 2023-12-11 14:40:58 发布
本文介绍了一种通过AssetBundle加载3D模型的方法,并支持中文路径。该方法使用FileStream读取文件内容到byte数组,然后调用AssetBundle.LoadFromMemory加载资源。通过遍历所有加载的资源找到GameObject类型的模型。
1465

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



