Hello Guest

Author Topic: FinishLoad event?  (Read 7291 times)

VeTaL

  • Newbie
  • *
  • Posts: 18
    • View Profile
FinishLoad event?
« 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).

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: FinishLoad event?
« Reply #1 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.

VeTaL

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: FinishLoad event?
« Reply #2 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
« Last Edit: May 12, 2012, 12:00:31 pm by VeTaL »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: FinishLoad event?
« Reply #3 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.

VeTaL

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: FinishLoad event?
« Reply #4 on: May 12, 2012, 12:59:21 pm »
Ok, i'll share working results, if needed :)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: FinishLoad event?
« Reply #5 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.

VeTaL

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: FinishLoad event?
« Reply #6 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());
}
}