After a week of time, almost solved the problem must be recorded.
The main difficulty is that PNG files will appear white-edged after converting to bytes file.
C #-How can I programatically load a texture to an Image the same means the Unity Editor does? This place explains the problem in detail.
Because our project will use a lot of image resources (PNG format), but there is a very big problem on iOS system, iOS will default to the maximum format to save the picture. This will cause the package to be very large after installation.
Like what
In unity, it expands into a
More than 10 times, and iOS is the size of the expanded, calculate how much space to occupy the picture, so when this image once hundreds of thousands, will lead to the installation package and the final app size difference between the very far, our game installs the package more than 160 m, the last app is 1G (OMG).
Then I follow reducing unity game file size This blog idea to change the original process of processing this picture, the main idea is: bypassing Unity's content pipeline and loading the Textur Es from the. png files in real time. The practice is to change the image file from the. png file suffix. bytes suffix as a binary file save, at runtime by Texture.loadimage (byte[] bytes) API to load the image.
But a magical thing appears, there will be a lot of edge lines between the different pictures
Like this situation, asked the next main course, said the original picture in the resources in the import will be the Generate MIP maps uncheck, and check the alpha is Transparent, but I set in the code has no effect, Later, I wanted to save the original. png file in unity by expanding it and then exporting it as a. bytes file, so this is a strange problem, but it is not good to find this way, because such a. bytes file will also be the expanded size, For example, the above hand bag picture will be saved according to 143.9KB.
Then found in Unity answers a PNG file will have white edge reason analysis, messy Alpha problem, presumably because in Photoshop, 100% transparent place the default color value is set to white, This will lead to the runtime, do the picture interpolation operation, because such 100%transparent point of interference use will appear white edge situation, Daniel proposed the solution is, in PS, using plug-ins for these 100%transparent points, Fill the color of adjacent pixels, and because of our picture resources too much, so that the art of a change picture is not realistic, so refer to a piece of Google code, through the code to complete the PS interpolation line workflow. PNG Transparency have white border/ Halo, there's this code in this issue. This problem basically solves, but looks like the performance consumes too much, does not know everybody has the better method, or everybody in the iOS platform for a lot of. png images will be handled
Questions about PNG images with white edges in unity