How do I pre-load a level before using it on iPhone Basic?

How do I pre-load a level before using it on iPhone Basic?

The problem I am encountering is that I start on Scene 0, after a certain amount of time has passed I load the next level using the following:

if(Time.realtimeSinceStartup >= 5)
{
     Application.LoadLevel(1);
}

On Scene 1, I have 3 simple SpriteManager2 sprites ( 1 atlas ) each rocking back and forth using a 48 frame animation take from Maya ( simple rotation on Y axis )

I run this on my iPhone, and as soon as it goes to load the Scene 1, the animation in that scene ( which starts immediately ) hiccups or hitches for a moment, then resumes. The scene runs at 58fps according to the GUITexture with a simple FramesPerSecond javascript I got of the wiki. Interestingly enough, if I hit the home button on the iPhone and immediately restart the game, I see no hitching ( guessing it is all cached ).

I am unsure how under iPhone Basic I can do some sort of background loading using something like Application.LoadLevelAsync, as it seems that this is only available under Unity Pro.

Any thoughts or tips would be appreciated.

One thing you could try doing is, instead of delaying the loading of the second level, consider loading the level as soon as possible but blocking the camera.

One technique I used for a previous iPhone project was to load a scene, having a “loading” image in front of the camera, then loading all the scene objects, materials, etc, and then removing the image in front of the camera.

I found this a good way to prevent any sort of stuttering when loading a scene.

That sounds like a good idea, though not what I was hoping for.

I was already going to use a fade from black ( black image in GUITexture ) The problem being that I can see the stutter through the fadeUp.

The other problem is that I have to sort of guess how long to keep the black texture up before deciding it is time to show the scene. All the while my animation is already playing back. I am not sure if it is the actual playing of the animation or the scene loading that is making it stutter, but it REALLY isn’t much data at all in the scene. Really makes me wonder…

It would be REALLY be nice to have a cached load and a signal to when it was ready to be displayed…

Anyone else have anything to add to the discussion? Any other alternatives? Does Unity iPhone Pro even offer an option to help this?

I’ve cached things before simply by turning them all on, yield, turn everything that isn’t required off, yield, then doing a fadeup.

It’s not… ideal… but it works :slight_smile:

Thanks JT, I had been looking through PirateNinjaAlliance’s posts and saw his method to get around basically the same issue as I had described, which is pretty much the same thing you just described. I think it work just fine.

Thanks!