Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Misthra-Games · Jan 16, 2016 at 08:24 AM · c#sceneloadscene-loadingcurrent

Get current scene number

Hey. I was wondering if anyone could tell me how to get the current scene NUMBER. I know how to get the current scene. But what im trying to do is something like "int nextScene = currentScene + 1;" So that i can load the next scene no matter what scene it is. Could someone tell me how?

Comment
Add comment · Show 1
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 vintar · Jan 16, 2016 at 12:30 PM 1
Share

I think maybe Scene$$anonymous$$anager.GetActiveScene().buildIndex.

But note from the docs :

Returns the index of the scene in the Build Settings. Always returns -1 if the scene was loaded through an AssetBundle.

3 Replies

· Add your reply
  • Sort: 
avatar image
7

Answer by Alakanu · Feb 23, 2016 at 02:07 PM

Hey man, I was having the same struggle today. I think the solution is

sceneID = SceneManager.GetActiveScene().buildIndex;

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 echoMike · Oct 23, 2017 at 06:50 AM 0
Share

That's very helpful. It appears that I'm still not fully understand Struct, which is why I'm searching for this.

avatar image
0

Answer by hexagonius · Jan 16, 2016 at 12:58 PM

I think grabbing all scenes, writing them to a static array and then getting the index for the current scene of that array might be a good idea:

http://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.GetAllScenes.html

Comment
Add comment · 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
0

Answer by x_mtd_x · Mar 18, 2017 at 05:46 PM

 //in top of youre script
 using UnityEngine.SceneManagement;
 
 
     // gets the curent screen
     Scene sceneLoaded=SceneManager.GetActiveScene();
     // loads next level
     SceneManager.LoadScene(sceneLoaded.buildIndex +1);

thats the new trick greethings Mathieu Dijkstra

Comment
Add comment · 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

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

63 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can you help me to find a script for collision a sphere to an object and change the scenes in the same time ? 1 Answer

Scene not loading on build but on editor it does. 0 Answers

Cannot interact with new scene 0 Answers

How do i create a scene variable? 3 Answers

Scene IS added to build settings: "Scene couldn't be loaded because it has not been added to the build settings" 7 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