We are building an app in 2d /orthographic camera. The project consists of around 15 scenes.
We use PSD straight into Unity and in Import settings we use:
In each scene it consists of around 80 objects with textures.
Example from first scene:
Background is 2048 RGB Compressed PVRTC 2 bits.
14 objects/texures are 1024 RGBA Compressed PVRTC 2 bits.
27 objects are 512 RGBA Compressed PVRTC 2 bits. (Within these objects I have 2 textures in projectfolder which creates 2 materials that when pressing the object switches between the 2 materials).
16 objects are 512 RGBA Compressed PVRTC 2 bits. (these only have one texture/material, no switching)
12 objects are 256 RGBA Compressed PVRTC 2 bits.
8 objects are 128 RGBA Compressed PVRTC 2 bits.
Shaders we use are Unlit/Transparent for all of them, except for the background that uses Unlit/Texture. (not sure if these are standard in Unity or if I got them from somewhere).
When I check Activity monitor in Xcode it runs heavy. It goes over 300 mb in memory and somethimes when I load a new scene it goes to high and goes black and closes the app.
I use no atlas, because I dont know that much about it and not sure if it helps me?
Audio
Audio is native wav when added to Unity and then it is compressed
Audio Format compressed (mpeg)
3d sound disabled
Load type Stream from disc
Hardware Decoding enabled
Compression 128 kbps
Text
We use GUI text, and have it set to White!
Shader GUI/Text Shader - Any other shader that is better to use here?
Fontsize 36 (on GUItext the font size is set to 0 and normal).
Unicode
Strong Antialiasing
2.x font Placing disabled
We also have set Texture type to Advanced,
Non power of 2 “None” .
All textures are squared.
We have disabled mip map.
Read/write is disabled.
Import type Default
Alpha from Grayscale disabled
Bypass sRGB Sampling disabled
Wrap Mode Repeat
Filter Mode Point
Anyone have any ideas, suggestions on why memory consumption is so high? What should I do to lower memory usage?
I have such a problems too. But I’m glad to find out that I’m not alone.
You know, 300 MB is really too much. For example, it’s recommended not to ran out of 80 MB on iPad1Gen…
The first thing that came to my sleepy head is to change most of sounds (especially small) by setting “Load type” to “Compressed in memory”. It’s not really big optimization, but it could help to free some space.
Let me guess. Probably, now you have links on necessary prefabs like:
public GameObject somegameobject;
So you just drag prefabs in inspector. Am I right? If yes, then you should know that it’s all loaded into memory at the beginning of the scene. It’s quite wrong approach for mobile devices. I think you should use Resources class. It could be helpful for you, 'cause you can Load into memory only necessary objects and then Destroy and Unload them. So idea for each necessary object: Load-Create-Use-Destroy-Unload.
upd. Also, the amount number of GameObjects could increase memory. For example, about few thousands of “empty” GameObjects (with only Transform component on it) gives above 5 MB (numbers are very inaccurate, but you’ve got the idea).
Hi,
Are you loading just the assets you need and unload those you are finished with ? Per level ?
Try to have a read at the resources class in the documentation, it could help.
Everything “transparent” is also quite expensive for the framerate, if nothing else. And you have lots of “RGBA” textures in there. If there are multiple layers of transparent surfaces drawn over each other, that gets extremely expensive on an IOS device.
Thank you all for your replies. I will investigate what you have written. By the way, we don´t use any prefabs at all at the moment.
The app we are working on is an interactive children’s book. Most of the objects/textures are active in the scene at all time. Some of the objects we can merge with the background picture and that maybe will lower the memory cost, but a lot of them needs to be separated from the background in order for them to be behind/infront of other objects and move/be interactive.
I think that right now everything loads in at load of scene. But on the other hand, almost nothing is removed from scene during “game time”.
A thought I was just thinking about now though, is if it matters what size we have set the Orthographic size to and the texture/objects. Right now we have the Orthographic size set to 11.25 for Ipad and 10 for Iphone. The background is set to 30 x 30 x 1. All other objects are scaled to the size we feel is good when placing them in the scene. Would it matter if we changed this in some way?
Thank you for the offer but I think Ive found the problem now. Yesterday we just tried reducing the images in Photoshop by half the size and then after that the app run around 100 mb instead. However this is not the solution.
Today I started reading up on textures sizes and such again and was watching a tutorial and saw the preview window in the texture importer and realised that I hadn’t seen that in my Unity. So I checked and found that it gotten hidden by all other windows at some point. Now I could see what size the images actually were at. Then I realised that on all the textures it said (npot) 32 ARGB, and so there is a problem with the power of 2 obviously.
So now I know that. And as far as I understand it I need to have the textures sized to 128x128 and 512x512, it is not enough to have them squared as we thought? They are all random now, like 138x138 etc.
However now I saw that the compression makes the images look crappy, so tomorrow I will go back to original picture sizes and export them from Photoshop with 2048x2048 for background 1024x1024, 512x512 etc for rest of the objects according to what they are closest to in Photoshop and then try different compressions and such. Just a bit worried now about how it will look in the end.
So after a few days of testing and working with our pictures and combining stuff etc we are now down to around 50 mb/scene. I hope that this is a good value to be on