Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by joeybubble1 · Nov 13, 2011 at 01:17 PM · scene-loadinglevelcheckload level

Check if level has been loaded?

Hi, how can i get a script to check if a level has been loaded?

Thanks.

Comment
Add comment · Show 7
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 syclamoth · Nov 13, 2011 at 01:37 PM 0
Share

In what way? What's wrong with using the

 OnLevelWasLoaded(levelNumber)

callback? Are you talking about asynchronous level loading here? The other kind only ever happens within one frame- it tends to manifest as a massive lag spike as it loads all the resources in.

avatar image joeybubble1 · Nov 13, 2011 at 01:42 PM 0
Share

ok, what i'm trying to do is check if the first level has been loaded, and if it has been, then on the main menu, create a button that leads to the level.

avatar image syclamoth · Nov 13, 2011 at 01:58 PM 0
Share

Define 'loaded'. Do you mean 'has been loaded in the past' or do you mean 'is currently loaded'? You can't load a level in the background and then keep it 'on hold' so to speak until you want to enter it- the level appears as soon as it gets loaded. Of course, there are ways of faking this. What exactly are you trying to do?

avatar image joeybubble1 · Nov 13, 2011 at 02:11 PM 0
Share

Yes i mean has been loaded in the past

avatar image syclamoth · Nov 13, 2011 at 02:18 PM 0
Share

Well that's easy then. Do you have any persistent objects? Do you want it to remember this between sessions?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by syclamoth · Nov 13, 2011 at 02:25 PM

Well, I'm going to go straight ahead and answer what I think your question is (which, if I'm wrong, should teach you not to ask one-line questions).

You should use PlayerPrefs for this stuff- it'll remember between sessions, as well as between scenes without needing any persistant objects.

 // when you load the level for the first time
 if(PlayerPrefs.GetInt("HighestLevelLoaded") < Application.loadedLevel)
 {
     PlayerPrefs.SetInt("HighestLevelLoaded", Application.loadedLevel);
 }
 
 // In your menu script-
 int jumpToThis = 0;
 while(PlayerPrefs.GetInt("HighestLevelLoaded") <= jumpToThis))
 {
     if(GUILayout.Button("Load Level: " + jumpToThis))
     {
         Application.LoadLevel(jumpToThis);
     }
     jumpToThis++;
 }

This will give you a list of numbered buttons for levels up to the highest one yet loaded. You can do whatever you like here- this is just an example.

Comment
Add comment · Show 1 · 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 joeybubble1 · Nov 13, 2011 at 02:56 PM 0
Share

thansk you!!!

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Playerprefs.SetInt Problem 1 Answer

Loaded 2 async scenes: how to unload or remove 1 of them? 1 Answer

How do I load previous levels individually in the build settings in unity3d 0 Answers

Classic Resident Evil-style room loading/level streaming? 4 Answers

Allow userto load custom unity levels/scenes. 2 Answers


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