AssetBundle.Unload(true) cannot unload the atlas

1) AssetBundle.Unload(true) cannot unload the atlas
​2) Questions about the preloading of Unity 2D game maps
3) Can Addressables support some resources to load source files directly without typing the Bundle


This is the 342nd UWA technical knowledge sharing push, which selects hot topics in the UWA community, covers UWA Q&A, community posts and other technical knowledge points, to help everyone master and learn more comprehensively.

Loading

Q: As shown in the picture, there is still an atlas left in the memory in AssetBundle.Unload(true), which can be unloaded by using Resources.UnloadUnusedAssets(), but cannot be unloaded by GC.Collect. If you do not call Resources.UnloadUnusedAssets(), there are other Is there a way to uninstall this gallery?

A1: Currently, Atlas in Unity 3D does not require additional uninstallation operations. You only need to ensure that the AssetBundle of Atlas and the AssetBundle that references Atlas are completely uninstalled, and Atlas will be uninstalled naturally.

Thanks to Mufeng@UWA Q&A Community for providing answers

A2: You can try Resources.UnloadAsset. In my impression, switching scenes will automatically call UnloadUnusedAssets.

Thanks to Knight-132872@UWA Q&A community for providing answers


Loading

Q: Excuse me, how does the 2D game map realize the seamless preloading function of the map? What do you need to learn specifically to write the relevant code?

A1: Assuming that the previous level is x-1, this level is x, and the next level is x+1, it is enough to preload the number of x+-y levels in advance according to the needs, and use the level ID to calculate the range to be loaded. The range is recalculated according to the level when switching levels.

Thanks to Cao Pangan@UWA Q&A Community for providing answers

A2: Use a tool to explain the idea of ​​LDTK .

The exported data is in units of levels. When entering the target level, it is necessary to load the adjacent levels in a queue. If the freeze experience is not good during the loading process, it is necessary to predict the next target level and use other visual effects to cover the loading freeze.

Another is to load all the levels, and the level transition is basically insensitive. This kind of problem needs to be considered to solve the problem of memory and efficiency.

The specific code implementation is to use the API provided by the tool, and there is no problem with programming foundation.

If it is Unity, it involves concepts such as resource loading and scenes.

Thanks to Li Wei@UWA Q&A Community for providing answers


AssetBundle

Q: Can Addressables support some resources to directly load source files without bundling, such as mp4, bytes files, etc.?

A: Addressables is also based on Bundle. If a file such as playing mp4 is in Bundle, it may be played incorrectly. You can read out such a file when the resource is updated and put it in the user directory of the device. You can use the file directly when using it. or path down.

Files such as bytes can be placed in the Bundle. A new method has been added to a certain version of TextAsset. This method can be used:

public NativeArray<T> GetData<T>() where T : struct;

For a large number of data tables, only one ByteBuffer is required for processing. If the stored data can be read in blocks, the memory will not take up much.

Thanks to Li Wei@UWA Q&A Community for providing answers

The cover image comes from the Internet


That's all for today's sharing. Life has a limit but knowledge has no limit. In the long development cycle, the problems we encountered are just the tip of the iceberg. The UWA community is willing to accompany you to explore and share together. More developers are welcome to join the UWA community.

UWA official website: www.uwa4d.com
UWA community: community.uwa4d.com

Guess you like

Origin blog.csdn.net/UWA4D/article/details/131638095