How to disable mipmap atlas generation in SpriteKit? - ios

When I add my game images to an atlas, the game's bundle size explodes fourfold.
Even with the RGB565_COMPRESSED setting I see a drastic increase in bundle file size. When I just add the image files to the Xcode project without generating an atlas, the bundle file size is a lot smaller.
My images in the atlas folder are 128x128 tiles only.
I suspect that Xcode is generating a lot of mipmap atlasses that I don't need for my game because there are no zoom levels. How can I suppress that or reduce atlas file size further?

Related

Texture in texture atlas is available in Xcode in a scene but not in running app

Using Xcode 8, I have a texture atlas with a bunch of images in it in my project. In the scene editor, I can select a sprite and in the Texture field for thats sprite I can click and get a list of all textures (images) in the project, INCLUDING those in the texture atlas. I select a texture from the texture atlas. When running the app I don't get the texture on the sprite. I get a big red X.
I know I can programmatically get a texture from the atlas and assign it to the sprite. I want to know why the Xcode (IB) assignment to the sprite works inside of Xcode (IB) but not in the running app. I should be able to assign textures from texture atlases inside of Xcode to a sprite.
If I assign a texture from a normal graphics image not in the atlas it works.
Can you select the Assets.xcassets file and see in the File Inspector (far right, first icon, looks like a paper page) if your target is checked in the Target Membership list? This is usually an excellent reason not to get any images from the asset catalog.

Best way to compress textures in Unity for iOS (game is way too big)?

I have looked everywhere and at Unity iOS Build size is way big, and after building my game for iOS it is way too big at 170 MB. I checked my player size statistics in the editor log and 96% of the size is textures - this is because as I was going into this box and maxing out everything (I did not know what I was doing):
Now I need to go back and reduce my asset sizes. I don't know a lot about texture compression so I need to know - for iOS (and Android later), what are the optimal settings in this override box for compressing textures to minimum size?
Is there a way to do this to multiple images at once? What should the compressor quality be?
This is a great time to learn about the AssetPostProcessor! Specifically, AssetPostProcessor.OnPreprocessTexture will allow you to automatically handle the import settings of textures in your Unity project. It will modify their meta files as they're imported and Right-click > Reimport will force them to run (you can use this on a whole directory; even the whole Assets directory).
As far as which settings you should use, that's entirely dependent on your project. A few thoughts:
Make sure your Max Size is appropriate for the textures. Icons don't need to be 4k and background images shouldn't be scaled down to 256.
Compressor Quality "Normal" is fine in most cases. Any compression is far better than no compression.
We use "Compressed ETC2 8 bits" on Android and "Compressed PVRTC 4 bits" on iOS.
Whether or not you use "RGB" vs "RGBA" is important to consider; textures that don't need an alpha chanel would be wasting memory if you choose "RGBA" and textures that do need one wont function properly if you choose "RGB".

What is the correct procedure to create images/sprite for iPhone/iPad apps/games?

I am new in developing games with Xcode for iPhone/iPad. Thus I need some help with the correct procedure to create images/sprites for the game.
By now I have created my sprites with Illustrator and I exported them as PDF files. In Xcode I created this single scale asset and put the PDF in it.
If I understand the documentation correctly, Xcode automatically generates image files at #1x, #2x and #3x from the PDF. Does it generate PNG files?
Then I create a SKSpriteNode and set the size like this: abc.size = CGSize(width: 123, height: 123). Instead of 123, I fill in the width and height corresponding to the frame/image size I set up in Illustrator. Is this correct? I think so, because this is #1x version?!
But if I need the same image for iPhone and iPad in different sizes, i can't simply resize it, because the #1x image version isn't a vector anymore and bounded to the frame size I chose in Illustrator? What to do then? Do I have to resize my image in Illustrator and export it in a different size?
What is the correct procedure? Do I have to draw a sketch with pencil at the very beginning on a paper and the measure it with ruler? Then I would go to illustrator and set the frame width height at that what I measured manually?
So many questions. I am very confused with this images sizes, resolutions and #1x, #2x and #3x version. I am not sure why I should use vector files, if I still can't resize the images in the developing process as I would like to, because they are still bound to the frame size I chose in Illustrator.
Is there no possibility to set ratios between all my images and then just use the vector PDF file? How should I setup my Illustrator?
I hope somebody can bring some light into the dark. Thank you.
Your pdf should be sized in points #1x (not pixels). The points should be the same physical size on the phone and the ipad, but if you want them smaller on the phone you need a second set of images; the asset catalog lets you swap out images based on iphone/ipad. Xcode renders your pdf to png's #1x, #2x and #3x and your app will pick the correct png based on the resolution of the device. You are correct that these are no longer vector assets and that scaling them up could leave you with blurry/pixelated images. You have a couple of choices:
1) include a scaled up version of your image at its maximum scale in app and use this version only when you need to scale up (otherwise its a waste of memory and processing if you are always rendering a much smaller image). This is probably the easiest solution.
2) leave your assets as vectors and load them as vectors, You still can render them to images for performance at a constant scale or range of scales, but you can always re-render them at any scale if needed. Most likely you want to use an SVG library for this.
3) You can directly import your assets as code using a program such as paint code. There used to be similar plugins for illustrator but I haven't seen one for Swift 3/Illustrator CC. This is obviously faster than #2 since there is no need to decode the vector file. If your file has a lot of overdraw you may still want to rasterize to images for performance.
Here's what I've found from my experience:
1) Xcode does not generate #2x and #3x from .png files. It can't really - you need to manually supply #1x, #2x, and #3x sizes.
2) Whatever size you use for the CGSize(...), that should be your #1x image, then generate #2x, and #3x from that. I started by designing the size of a level in the scene editor, then made a generic SKSpriteNode shape just to get the size I wanted, then I started making the image from the size I found that looks good.
3) Xcode supports vector based graphics (svg, pdf), but you can't use them as part of a texture atlas, which makes them much less useful in my opinion.

How to handle multiple atlas files

I have a bunch of images in a folder name myImages.atlas. These images when put together will take up more than 2048x2048. Based on the Apple documentation I would have expected XCode to automatically break this up into multiple files.
After an image has reached its maximum size, a new image is created.
But when I try to compile it fails with the error:
sprikekit texture atlas generator error cannot fit input texture into a maximum supported dimensions of 2048 x 2048
Does anyone know if it's possible for XCode to handle this sceanrio and if yes what might I be doing wrong?

How to analyze ios ipa files info for reduce file size?

I want to reduce compiled file size of ios ipa file.
I get "How to reduce" way: How to reduce the size of my iPhone application?
But I want to know "How to analyze" way:
My image is
$ du /path/to/app
100 /path/to/app/images
150 /path/to/app/sounds
And I wan to reduce file size on effective point. Visualization is more good!:
http://www.lomont.org/Software/Utilities/DiskInfo/DiskInfo.png
I know I should delete files which is not used but is linked project...
I have used a tool called [ImageOptim] (http://imageoptim.com/xcode.html)
It incorporates a number of tools inside which crush your png files significantly (in my case it was between 25% to 50%) and had reduced the size of my app of around 0.6 mb
One thing to remember is to disable Xcode's PNG optimization.
There is no magic way to reduce the file size of ipa file.
What you can do to reduce the size are just as you said,
Remove any unnecessary files
If you have a lot of images, consider using PNGCRUSH to reduce file size of images
If you have a lot of sound files, consider using compressed audio file such as MP3, also, consider changing to mono instead of stereo. Bit rates of around 96K is still pretty decent.

Resources