• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by moghes · Mar 21, 2013 at 01:31 PM · loadlevelpreloader

Current scene execution stops before next scene is fully loaded!

Hello,

I have a separate scene named "Loading" , which I load before any "big" scene is loaded. Of course scene "Loading" is light and almost empty which loads fast. I want to display cool staff inside this scene and since every time I want the same loading animation to appear, I preferred to have a separate scene.

Here's the script that manages the "Loading" scene.

 public var backgroundGUI:GUITexture;
 public static var levelToLoad:String;

 function Start () 
 {
      backgroundGUI.pixelInset.width = Screen.width;
      backgroundGUI.pixelInset.height = Screen.height;
 }
 
 function Update ()
 {
     if(Application.GetStreamProgressForLevel(levelToLoad) == 1)
     {    
         Application.LoadLevel(levelToLoad);        
     }
 }

And here's the script that Loads this scene:

 // of course this if conditional is inside GUI , checking for touch , etc ...
 if(button1_guiTexture.HitTest(Input.GetTouch(0).position , mainCamera))
 {
     levelButtonSound.Play();                                
     LoadLevel("Jungle");                 
 }
 
 function LoadLevel(levelToLoad:String)
 {    
     Loading_Manager.levelToLoad = levelToLoad;
     Application.LoadLevel("Loading");
 }


As you see clearly in the code, I change the level name and load the "Loading" scene, which in turn plays a Background and Loads the appropriate Scene.

What I can't do is applying any animation or percentage display or anything once Application.LoadLevel(levelToLoad) is called.

I need a way to keep the Update function running untill the next level fully loads. Or any other different method that can make this work.

Thank you for your time :)

Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Bunny83 · Mar 25, 2013 at 04:55 PM

This is only possible with Application.LoadLevelAsync which is a unity pro feature. The normal LoadLevel function blocks until the level is loaded. No frame is drawn during the loading.

Comment

People who like this

0 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image moghes · Mar 26, 2013 at 09:16 AM 0
Share

@Bunny83 thanks, it seems to solve my problem, but causing me another strange problem!

The game is not playable! so strange, the assets shake, even the touch control stops ocasionally .. some type of crash, I switched back to the old method, everything runs smoothly now.

I did use it like this: Application.LoadLevelAsync(levelToLoad); Just like LoadLevel.. what might cause this?

avatar image moghes · Apr 03, 2013 at 12:37 PM 0
Share

Well , I created a separate scene for loading, and put the "Application.LoadLevelAsync" in the start function of the the loading scene.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to have GearVR play smooth during LoadLevelAsync 0 Answers

FadeAndLoadLevel? 1 Answer

Loading level using a string created through code. 3 Answers

Unity script to open a new scene 3 Answers

LoadLevel isn't working, help? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges