Hi guys I am working on a project that downloads lots of textures, many of them for a cube map, places them , and then once the player changes their options we unload and the textures and begin loading our new set of images . I wanted to know is their a more efficient way that I can be doing this I have recently begun to encounter some memory issues on both android and iOS machines .
Here is an example of unloading one group of our images :
public void UnloadTextures(){
Resources.UnloadAsset(leftPano);
Resources.UnloadAsset(rightPano);
}
private void UnloadTextures(Renderer pano){
Material[] mats = pano.materials;
for(int i = 0; i < mats.Length; i++) {
Texture2D tempTex = mats *.mainTexture as Texture2D;*
-
DestroyImmediate (tempTex,true);*
-
}*
-
Resources.UnloadUnusedAssets();*
- }*
Here is a second example of unloading our texture in the project : -
Texture2D leftTemp = leftShutter.texture as Texture2D;*
-
Texture2D rightTemp = rightShutter.texture as Texture2D;*
-
leftImage.texture = (Texture)PortalCache.LoadImageFromCache(downloader.DownloadedImageLibrary.leftSpinPaths[index]) as Texture;*
leftShutter.SetNativeSize();
-
rightImage.texture = (Texture)PortalCache.LoadImageFromCache(downloader.DownloadedImageLibrary.rightSpinPaths[index]) as Texture;*
rightShutter.SetNativeSize();
-
Resources.UnloadAsset(leftTemp);*
-
Resources.UnloadAsset(rightTemp);*
Is there anything I can be doing that is more efficient in terms of unloading these textures? As I mentioned I am also downloading them from web , So perhaps there is an efficient way to manage downloading of textures from the web ?