2D Toolkit Forum

2D Toolkit => Support => Topic started by: VeTaL on May 12, 2012, 10:24:14 am

Title: FinishLoad event?
Post by: VeTaL on May 12, 2012, 10:24:14 am
Is it possible to have such kind of event? As i told before, i have lots of quite heavy animation. I'd like to know, when it loads completely (to show a loading screen, or so).
Title: Re: FinishLoad event?
Post by: unikronsoftware on May 12, 2012, 11:42:26 am
You have to deal with this like with any other Unity object. If you have the animation in a second scene, you can use Application. LoadLevelAdditiveAsync to load your level while your "Loading..." level is in the foreground. Once the level has loaded, you can hide and destory the "loading" object.
Title: Re: FinishLoad event?
Post by: VeTaL on May 12, 2012, 11:47:37 am
And what about first level?

Should i use it this way ?
1) show a picture (or animation) with "Loading" line - actually, not just a picture, but a whole level
2) during it, Application.LoadLevelAsync 
3) when finished, destroy picture

PS: i hope, this one also would be useful for other users
Title: Re: FinishLoad event?
Post by: unikronsoftware on May 12, 2012, 12:42:39 pm
Yes pretty much that. You can do it on any level really, even for the startup scene.
Title: Re: FinishLoad event?
Post by: VeTaL on May 12, 2012, 12:59:21 pm
Ok, i'll share working results, if needed :)
Title: Re: FinishLoad event?
Post by: unikronsoftware on May 12, 2012, 01:11:28 pm
Oh yeah I should mention, if you intend on doing an animated loading scene, you'll need Unity pro as that function will block in the free version.
Title: Re: FinishLoad event?
Post by: VeTaL on May 13, 2012, 11:26:12 am
Pretty simple. I made an empty level with simple cycling animation. And this code, attached to object.

Code: [Select]
private AsyncOperation ao;

void Start()
{
ao = Application.LoadLevelAsync("Level1");
if (ao != null)
{
//GUI.Box(new Rect(0, Screen.width - 40, ao.progress * Screen.width, 40), "");
Debug.Log(ao.progress.ToString());
}
}