[Unity3D]如何创建图像文件夹的资产包,然后将这些图像加载为纹理?

[Unity3D]How to create an assetbundle of an image folders and then load these images as texture?

我是 Unity 新手。现在我有一个图像文件夹,其中包含大约 749 张 .jpg 图像。我想创建这个文件夹的资产包。在游戏中,我想将这些.jpg图像一张一张地加载并设置为Texture2D。

提前致谢。

您可以在 Unity 博客上找到完整指南(如何制作和加载资产包),如上所说:

AssetBundles are files created in the Unity editor during edit-time, which can be used later by a build of a project at run-time. AssetBundles can contain asset files such as models, materials, textures and scenes. AssetBundles cannot contain scripts. (Read This)

通过 WWW 或 WWW.LoadFromCacheOrDownload 下载资产包后,执行此操作:

WWW www = new WWW(url);//download aaset
                AssetBundle assetBundle = www.assetBundle;
                AssetBundleRequest request = assetBundle.LoadAssetAsync<Image>("nameOfImage");
                Texture texture = request.asset as Textute;

将此代码放在 IEnumerator 下并生成 return www;