Author Topic: How to make scene loading ?  (Read 3005 times)

mimmog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
How to make scene loading ?
« on: October 05, 2014, 12:48:46 PM »
Is possibile to create a loading screen for scenes with NGUI ? I would like also only the text "Loading..." without progress bar...I have not Unity Pro and I can't use Application.LoadLevelAsync and similar.

PS: It's enough also only a loading screen when the game start and to load all game's assets.

Thank you

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to make scene loading ?
« Reply #1 on: October 06, 2014, 08:44:25 AM »
Make a UI window that says "loading". Instead of just doing Application.LoadLevel, open that window first, yield until next frame, then do Application.LoadLevel.

mimmog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
Re: How to make scene loading ?
« Reply #2 on: November 29, 2014, 09:19:42 PM »
Like this?

  1.  
  2. VisualLoadingScreen();
  3. yield WaitForEndOfFrame();
  4. Application.LoadLevel("1level");
  5. DisableLoadingScreen();
  6.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to make scene loading ?
« Reply #3 on: November 30, 2014, 05:50:57 AM »
WaitForEndOfFrame() is still the same frame. "yield return null;" would wait for the next one.

mimmog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
Re: How to make scene loading ?
« Reply #4 on: November 30, 2014, 11:59:39 AM »
No, not work fine... :( this is the code :

  1.  
  2. public void loadLevel(int numL){
  3.                 string levelName = "Level_" + numL;
  4.                 setLevelInfo (numL);
  5.                 StartCoroutine(waitLoading(levelName));
  6. }
  7.  
  8. IEnumerator waitLoading(string levelName){
  9.                 NGUITools.SetActive(menuLoading,true);
  10.                 yield return null;
  11.                 Application.LoadLevel(levelName);
  12.                 NGUITools.SetActive(menuLoading,false);
  13.                
  14. }
  15.  

The problem is that It not show the menuLoading but if I delete the row NGUITools.SetActive(menuLoading,false); the menu is showed..why it not wait for NGUITools.SetActive(menuLoading,false); ?
« Last Edit: November 30, 2014, 01:40:23 PM by mimmog »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to make scene loading ?
« Reply #5 on: December 02, 2014, 11:16:05 AM »
You would need to wait for the level to load instead of executing the code right away. Check Unity's documentation for Application.LoadLevel, this isn't an NGUI question at this point.