Hello Everybody
I've bought NGUI recently, so I'm relatively new to the subject.
I'm developing a game for iPhone, iPad and Android and I have lots of textures for the UI. Currently I have to use up to 25 different atlases only for the Tablet-UI (Tablet and Phone need special UIs). The Unity GUI was at it's limits, the game was brutally slow in the end, that's why I switched over to NGUI. But now, I've some trouble with the memory on older devices (the game should run on an iPad 1st Gen).
I dont want to publish a special version for retina displays. As shown in several tutorials, I have to use atlas-references. So now, when the game starts, I first check the device and screen resolution. Then the game loads all atlas-references and the right atlases (HD or SD) from the resources-folder (all atlases are in there). Then I set all the references (atlasReference.replacement) and the pixel size (atlasReference.pixelSize = 1 for HD, 2 for SD). This works great...
But the game always has the same amount of total allocated memory, doesnt matter if I load the HD or SD atlases. Unloading unused assets in Unity does nothing. So, am I doing something basically wrong or is there a way to tell Unity or NGUI not to load all atlases?
Thanks for your time,
*prox
Here's a little bit of code of what the game does with the atlas references...
[...]
atlasPath = "UI/Atlases/" + game.PlatformType.ToString();
atlasReferencesPath = atlasPath + "/References";
Object[] atlasReferenceObjects
= Resources
.LoadAll(atlasReferencesPath,
typeof(UIAtlas
));
foreach (UIAtlas atlasReference in atlasReferenceObjects) {
UIAtlas atlas
= Resources
.Load(atlasPath
+"/"+ atlasReference
.name +"_"+ pscreenType
.ToString(),
typeof(UIAtlas
)) as UIAtlas
;
if (atlas != null)
{
atlasReference.replacement = atlas;
if (pscreenType == ScreenType.HD) {
atlasReference.pixelSize = 1;
}
else {
atlasReference.pixelSize = 2;
}
}
}
Resources.UnloadUnusedAssets();
System.GC.Collect();
[...]
Resources folder looks like this, for example...
Resources/UI/Atlases/Tablet/References/Buttons
Resources/UI/Atlases/Tablet/Buttons_HD
Resources/UI/Atlases/Tablet/Buttons_SD