Optimizations within Unity for low memory devices

WaveLightGames

New member
Jun 19, 2014
282
0
0
Visit site
Hi guys,

I develop my games within Unity 3D and I was wondering if there are any tricks to get games to run on low memory devices? I use pretty heavy 3d graphics and I'd like to know exactly what the bottleneck is. Is it the size of textures for those devices? If so, there are settings within Unity that can be used to shrink textures significantly. Is there anything else? I'd really like to know what causes 3d games to crash on 512 MB devices.
 

Expression2

New member
Oct 2, 2013
79
0
0
Visit site
See if you could hook debuggers onto your game, and check for native runtime exceptions, since native DX is where things usually go wrong. You can choose to monitor native exceptions with CTRL ALT E in Visual Studio. Make sure you turn off Just My Code as well.
 

Expression2

New member
Oct 2, 2013
79
0
0
Visit site
Just my code means when debugging, the debugger only breaks if exceptions occur in your code, but not in external libraries, unless the exception thrown is lethal. Turning just my code off allows source stepping of external libraries (given that PDBs are available, and must be .Net assemblies). Unity runs on the .Net Framework so PDBs should be provided as part of the IDE/SDK.
 

WaveLightGames

New member
Jun 19, 2014
282
0
0
Visit site
For those interested, I managed to get my very graphics intensive game working on 512 MB RAM devices. I did it by setting up large audio files (background music) to stream rather than load into Memory and I also reduced texture sizes for Windows Phone builds and finally I wrote code within Unity to force graphics settings to a lower level (which further compressed textures) if the system memory is less than 600 MB. All of this was done within Unity. If anyone wants more details, let me know.
 
Nov 11, 2013
449
0
0
Visit site
For those interested, I managed to get my very graphics intensive game working on 512 MB RAM devices. I did it by setting up large audio files (background music) to stream rather than load into Memory and I also reduced texture sizes for Windows Phone builds and finally I wrote code within Unity to force graphics settings to a lower level (which further compressed textures) if the system memory is less than 600 MB. All of this was done within Unity. If anyone wants more details, let me know.

Amazing if all developers, even big; do the same like you.
Congrats!
 

WaveLightGames

New member
Jun 19, 2014
282
0
0
Visit site
Thanks .... I was thinking lately that there really is no excuse for not having games work on 512 MB devices. Here's some screenshots of some updated graphics I'm doing for my game that runs smoothly on a Lumia 520:

New Colours 2.pngNew Colours 3.png

These graphics will be in the next version ... currently, the lighting effects are different but still a full 3D game with gameplay, music, sound effects that runs smoothly on 512MB devices. It took me a while to figure it out (and that's why the initial release didn't support 512MB devices and I received a lot of bad reviews for it) ... but once I did, it works great.

Think of it this way, I believe the original Xbox 360 only had 512 MB memory ... think of the games that it could run.
 
Nov 11, 2013
449
0
0
Visit site
Thanks .... I was thinking lately that there really is no excuse for not having games work on 512 MB devices. Here's some screenshots of some updated graphics I'm doing for my game that runs smoothly on a Lumia 520:

View attachment 73343View attachment 73344

These graphics will be in the next version ... currently, the lighting effects are different but still a full 3D game with gameplay, music, sound effects that runs smoothly on 512MB devices. It took me a while to figure it out (and that's why the initial release didn't support 512MB devices and I received a lot of bad reviews for it) ... but once I did, it works great.

Think of it this way, I believe the original Xbox 360 only had 512 MB memory ... think of the games that it could run.


When you updated, don't forget to tell. Mine is 720, so is 512 :p
 

WaveLightGames

New member
Jun 19, 2014
282
0
0
Visit site
Sure ... you can download the game right now. Link

It should work fine on a 720 since it works on a 520. However, I did notice a recent review from a 720 owner saying the game wouldn't install ... which makes no sense since the installation part is handled by Microsoft. It's not something I could screw up even if I wanted to.

However, the graphics at the moment have inefficient lighting settings which (1) look garish and way too bright for a dungeon and (2) make the games download bigger than it should be. Next week, I'll post up an update that will have all the lighting upgraded to look way better and should also be a smaller download. You might want to wait but you could also pick it up now and let me know what you think. Here are current graphics ... not bad, but I think the new ones are way better and have a much darker / cooler atmosphere.

Promo Big.png
 

WaveLightGames

New member
Jun 19, 2014
282
0
0
Visit site
The major issue I have with games like Modern Combat 5 not running on a 512 MB device is that I think it's just laziness on the part of the developer. The major factors that eat up RAM in a game are:

1 - Audio Files loaded directly into memory
2 - Textures Files that are used to wrap around 3D objects

Most other stuff is tiny. Now any decent game engine (such as Unity 3D) allows you to stream the audio from disk rather than load to memory (which takes care of item 1) and compress the size of texture files (which takes care of item 2). Now, on a small phone screen ... having large textures is completely pointless. I found I could compress my textures by 4 to 8 times and still have no noticeable difference in game graphics. Compressing textures makes the 3D objects look blurry (at very high compression) but on such a small screen, it's barely noticeable. There is absolutely no reason any current Windows Phone game couldn't run on a 512MB device. It might not look as good as on a 2GB device but it should still be able to run smoothly and for the most part, the differences in graphics shouldn't be that noticeable ... if at all.
 

WaveLightGames

New member
Jun 19, 2014
282
0
0
Visit site
Sure, no problem.

Since this post, I've done some more work on optimizing and come up with a few other things. So in total, my optimization strategy is the following:

1 - Set all large music files (background music usually) to "Stream from Disc" and "Compressed" and uncheck the "3D Sound option". This is all just done in the Unity 3d Inspector screen when you select the music file.

2 - Select all meshes / skinned mesh renderers of objects used in your game and set the shader in the related material to Mobile / Diffused. I don't bother with normal maps and specular maps for a mobile game. Setting to a mobile ready diffuse shader cuts down the number of textures for that shader to just one. This is again done in the inspector screen in Unity when you select the material.

3 - For all textures being used in your game, make sure they are compressed as much as possible. Set the compression to "Compressed" or DXT5 if you're using Advanced settings. Now click the "Override for WP8" button in the inspector and select a low max texture size. Something like 32x32 for a small texture and 128x128 for a larger one. You can have the object using the texture on your scene view and then as you adjust the texture size, you'll see how it looks so you can experiment until you finding something acceptable. This is all done in the inspector screen again.

4 - If you are using Light Mapping (and I highly recommend it over dynamic shadows for performance reasons), you should also select the light map textures and reduce them to something small in the same way as you do for other textures.

5 - Animations can eat up a lot of memory if you are using the Legacy animation mode as I am. Therefore, for each object with animations, go into the animation compression setting in the inspector and make sure that animation compression is being sued. The default values of 0.5 / 0.5 / 0.5 can also be increased to something like 5 / 5 / 5 to reduce size of animation data and still get good results on mobile.

Now the above will apply to all Windows Phones so I would choose settings that look decent and not go too aggressive. Now you can use Unity's built in Quality Settings option to further compress textures and such. There is a built in one that further reduces textures by half. I would suggest, writing code that looks at the phone's memory and automatically changes the quality setting to that lower option if the memory is less than 512MB.

Is used the following script at my initial scene of my game. This is just attached to a game object in an empty scene.

**********

using UnityEngine;
using System.Collections;

public class QualityManager : MonoBehaviour {

// Use this for initialization
void Start () {

if (SystemInfo.systemMemorySize < 600)
{
QualitySettings.SetQualityLevel(0);
}

}


}

************

That all being said, I am running into difficulty getting my current game to run on a 512MB device. It's because it's a very ambitious 3D tactical RPG and gives the player a choice of 18 characters to choose from and can have lots of different enemies on the screen at one time ... all rendered in 3D graphics. So I suppose there are limits of what you can do but I really think this should be a very rare case.
 

Members online

Forum statistics

Threads
323,185
Messages
2,243,409
Members
428,037
Latest member
Brilliantick99