Unity 3D:资产捆绑与资源文件夹与www.Texture [英] Unity 3D: Asset Bundles vs. Resources folder vs www.Texture

查看:98
本文介绍了Unity 3D:资产捆绑与资源文件夹与www.Texture的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我在Unity 3D中有关AssetBundles和Resources文件夹的论坛上做了一些阅读,但我无法找出解决所面临问题的最佳解决方案.问题出在这里:

So, I've done a bit of reading around the forums about AssetBundles and the Resources folder in Unity 3D, and I can't figure out the optimal solution for the problem I'm facing. Here's the problem:

我有一个专为独立程序设计的程序,可以加载装满.png和.jpg图像的书".此刻,每次程序启动时页面都是相同的.在任何书"的场景开始时,它都会使用www.texture和路径立即加载所有这些图像.但是,我现在意识到,这可能是一种在运行时访问事物的性能不佳的方法-速度很慢!这意味着在场景开始并且加载了书的页面图像(在非传奇性计算机上)时,用户在5-20秒之内无法执行任何操作.所以,我不知道三件事中哪一个是最快的:

I've got a program designed for standalone, that loads "books" full of .png and .jpg images. The pages are, at the moment, the same every time the program starts. At the start of the scene for any "book", it's loading all those images at once using www.texture and a path. I'm realizing now, however, that this is possibly an non-performant method for accessing things at runtime -- it's slow! Which means the user can't do anything for 5-20 seconds while the scene starts and the book's page images load up (on non-legendary computers). SO, I can't figure out which of the three things would be the fastest:

1)每本书加载一个资产捆绑包(例如20个纹理,每个纹理1 mb).

1) Loading one asset bundle per book (say 20 textures @ 1 mb each).

2)每页加载一个资产捆绑包(每个1 mb).

2) Loading one asset bundle per page (1 mb each).

3)前两个选项中的任何一个,但是从资源文件夹中加载的.

3) Either of the first two options, but loaded from the resources folder.

哪个会更快,为什么?我知道资产捆绑包是统一打包的,但这是否意味着内部纹理将被预压缩并且在加载时更容易存储在内存中?资源文件夹会减少加载时间吗?是什么赋予了?据我了解,资源文件夹会加载到缓存中-但是它与独立播放器正常使用的缓存相同吗?还是这是多余的未使用空间?我猜另一个问题是,我不确定从内存中加载内容并将它们存储在缓存中有什么区别.

Which one would be faster, and why? I understand that asset bundles are packaged by unity, but does this mean that the textures inside will be pre-compressed and easier on memory at load time? Does the resources folder cause less load time? What gives? As I understand it, the resources folder loads into a cache -- but is it the same cache that the standalone player uses normally? Or is this extra, unused space? I guess another issue is that I'm not sure what the difference is between loading things from memory and storing them in the cache.

人们,干杯...

推荐答案

资源文件夹是捆绑的托管资产.这意味着它们将按照您在IDE中应用的设置由Unity压缩.因此,它们在运行时有效加载.您可以为每个平台定制压缩,这将进一步优化性能.

The Resource folders are bundled managed assets. That means they will be compressed by Unity, following the settings you apply in the IDE. They are therefore efficient to load at runtime. You can tailor the compression for each platform, which should further optimize performance.

我们大量使用Resources.Load()提取资产,并且在台式机和移动设备上均表现良好.

We make expensive use of Resources.Load() to pull assets and it performs well on both desktop and mobile.

还有一个名为StreamingAssets的特殊文件夹,可用于放置捆绑的非托管资产.这是我们将要播放的视频放在此处的位置,但不希望Unity将其转换为默认的ogg编解码器.在移动设备上,这些内容可以在本地视频播放器中播放.您也可以将图像放在其中,然后像使用WWW类一样加载图像.速度慢,因为Unity需要在加载时清理并压缩图像.

There is also a special folder, called StreamingAssets, that you can use to put bundled un-managed assets. This is where we put the videos we want to play at runtime, but don't want Unity to convert them to the default ogg codec. On mobile these play in the native video player. You can also put images in there and loading them is like using WWW class. Slow, because Unity needs to sanitize and compress the images at load time.

如上所述,由于处理资产的开销,加载WWW较慢.但是,您可以从服务器或应用程序沙箱"外部提取数据.

Loading WWW is slower due to the overhead of processing asset, as mentioned above. But you can pull data from a server or from outside the application "sandbox".

  • 仅当用户忙于浏览每本书的第一页时,才加载您需要显示的内容并实施后台过程以获取其他内容.这样可以避免将UI阻塞太长时间.
  • 优化图像以减小文件大小.如果您需要透明图像,请使用tinypng,或坚持使用压缩的JPG
  • 在可能的情况下尝试使用2张图片的幂.这样应该可以加快运行时处理的速度.

ath.

这篇关于Unity 3D:资产捆绑与资源文件夹与www.Texture的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆