Unity3d How to reduce the size of the package to the extreme, the picture is the most space in the game app resources, so please do not understand u3d to the picture file storage way to understand, see "unity3d-texture image Space and memory consumption analysis." Because U3d does not elaborate on the compression of resources, many projects have a headache when they encounter packet size bottlenecks. I am not immortal, also painful, but experience a few project toss, finally can comb out a set can reduce the size of U3D packet to a reasonable range of methods.
First, let's show what the official says:
(http://docs.unity3d.com/Manual/ReducingFilesize.html official manual)
1. Replace JPG, use PSD, reduce duplication of resources
2. Eliminate unnecessary resources
3. Check the log record when packaging to determine the file types that need to be reduced
4. Optimize, compress pictures, reduce image size
5. Optimize, compress grids and animations, reduce file size
6. Remove System.dll and System.Xml.dll, and try not to rely on them, or replace them with other components.
This official explanation is of little help to us. So, we still need the same weapon, Www.LoadFromCacheOrDownload. I divided the bag into three sections: 1. The first package (which contains the most essential resources). 2. First enter the package load (load the game to run the necessary resources). 3. The game runs in the resources load (according to each game different definition, takes the scene and the unit individual as the main, when the picture enters the load resource, after the load completes and then runs and displays).
For u3d assetbundle resource loading and package encapsulation, please see the Unity3d assetbundle Resource loading package for this article.
The point is, www.LoadFromCacheOrDownload after loading the assetbundle will be the extracted resources stored in the local folder, so although the download of the package is small, but the package is still very large after decompression. Workaround: First encrypt the resource bundle and name the. bytes suffix, and the last reload is not to be decompressed to the resource store again locally, because it does not recognize our encrypted assetbundle resource, and then reads the resource when it needs to use assetbundle.createfrommemory, the decoded 2 into the data becomes our available assetbundle.
This method can be used flexibly as follows: I encrypt the n resource pack into N 2 into the file, and then package the encrypted files again into 1 normal assetbundle files, using www. Loadfromcacheordownload when the load from the network, the local application stored on the time n our encrypted 2 into the file, and not be u3d extracted after the normal resource file. This further reduces the size of the local resources.
I passed the experiment to calculate, a do not do any compression method has 1G size U3d app, compression to the extreme, can be about 150MB, and this number when the whole packet size. If you do what I say three load, the first package can be pressed to within 50MB, some even 30MB (different games, different designs are not the same). Of course, in doing so, the whole package may be a bit larger because resource dependencies are split, so resources can be duplicated and avoided.
Unity3d How to reduce the package size to the extreme