I’m trying to create an extensive photo gallery by using the swipectrl I’ve bought. The images are in high quality (24bit) to avoid banding. But this limits me to approximately 10 images. If I go higher I run into memory problems on an iPad (escpecially iPad 1). I suppose this occurs because all images are loaded at the start. I’ve divided my gallery in several scenes but his is not really convenient.
Does somebody know if there is a component/script for sale which circumvents the memory problem (but keeps the swiping) by for example only the 2 images before and after the current displayed are kept in memory. If you swipe too fast (faster than the app can load the 2 before/after) the image needs to be loaded (small waiting time).
Does this seem sensible?
Any help is greatly appreciated!
Actually this is not easy, not even in Objective C.
The basic trick is to never have more than two images in Ram(well, if you speak of fullscreen slides). If you have something like a table, which displays a number of items (could be images) than you never have more items that fit inside there plus one.
So while you can come up with something like this in unity, its a hassle because:
- There are no such UIElements in Unity
- You usually need to have your images in a textureformat
- Thus no easy reading of png, jpg pdf and so on.
I guess you should research on how to display UIViews on top of unity and then use XCode to do the slide stuff.
Here are some hints:
- Well get familar with XCode and iOs development there
- Have a look at Prime31 plugins, he has somethinhg to show UIViews over unity
- in XCode you can either make all this yourself from the ground. Good ressource to learn is the videos of WWDC 2010 and 11. There are videos over: Create apps with scrollviews, which covers the topic.
- Other than that there are existing frameworks like Three20.
Markan, thank you for your reply.
I’m trying to keep it in Unity for development (Im not a programmer
).
I already own several plugins from Prime31. So I’m going to look at his site for the plugins to offer the UIviews. Thank you for that tip!
What about Resources.Load and Unload? Can it works?
Well if you want to keep it in unity, theeeeeen you don´t want prime31, as that only opens the door to xcode stuff.
Hmm, did you search the assetstore for slideshow? Maybe there is something.
Other than that, yes Ressources load is necessary (or a different loading thing), images must not be connected in the scene. Images out of view must be destroyed. Or you will crash after a dozen imageviews.
This is best done in cocoatouch.
But you can totally make a photo gallery via Resources.Load and Resources.UnloadUnusedAssets that will load images on demand.
Also you can if you make a script with these functions in it:
OnBecameVisible()
OnBecameInvisible()
Then put that script on an object, ideally the plane that holds your image. Then, as the functions signify, they will be called when that objects becomes visible, and when it becomes invisible.
So then you just do a Resources.Load in OnBecameVisible, then a texture = null; Resources.UnloadUnusedAssets in OnBecameInvisible.
If you want to use JPG or png’s, you can use the WWW class to do that.
Really getting images to load and unload dynamically is the easy part. The hard part is getting the touch input and animation working as nicely as a UISlideView in CocoaTouch.
This is very, very difficult to get right if you are “not a programmer.” I know, because it took me about 2 months to get something similar working, and I’ve been programming for a long, long time. I would highly recommend that you just do this in native UIKit with a UIScrollView, as Apple even provides example projects that can help you get started…
Your absolutley bang on with the resources load, unload, ideally rather than load all textures you should load one at a time and then unload, the problem comes at runtime counting the number of resources in an actual resource folder (i.e. number of images in gallery) or finding the just the paths without loading them, you can make an editor script to do this bit and fill in an array, before building, but I wondered if there was a way to find the paths available within the resource folder at runtime.