• 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 /
This question was closed Jan 09, 2020 at 01:21 PM by pako for the following reason:

The question is answered, right answer was accepted

avatar image
5
Question by nathanael_cassagnol · Dec 19, 2015 at 09:11 AM · scenescenes

Getting Scene index as int

Im trying to simply get the scene index as an int. With the new Unity.SceneManagment it should be easy but Im still experiencing problems.

I tried using Scene.BuildIndex but couldn't figure out how to get the index from the scene the script was in. And then I moved on to using SceneManagment.GetActiveScene and that has led to where I have the script attempt now which is

 SceneManagment.GetActiveScene = new int (y);
 int y = SceneManager.GetActiveScene();

although neither attempts are proving successful.

Is there any way to get the build index, as an int, from the current scene the.

Any help would be appreciated thanks

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

  • Sort: 
avatar image
27
Best Answer

Answer by allenallenallen · Dec 19, 2015 at 09:13 AM

 int y = SceneManager.GetActiveScene().buildIndex;

SceneManager.GetActiveScene() returns a scene and bulidIndex returns that scene's build index.

Comment
Add comment · Show 3 · 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 Voker54 · Apr 30, 2017 at 04:09 PM 0
Share

Just wondering. What is the buildindex and how come it returns an int?

avatar image allenallenallen Voker54 · Apr 30, 2017 at 04:19 PM 1
Share

alt text The top right hand side shows the build indexes for each scene.

avatar image kosmas12 Voker54 · Jan 09, 2020 at 01:20 PM 0
Share

2 years later I am here to answer in text. The build index is more like the order in which your levels are. The first one is 0 and then it goes up. It is also the number Scene$$anonymous$$anager.LoadScene() uses to load a scene.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

9 People are following this question.

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

Related Questions

How do i create a level lock system? 1 Answer

pre-load multiple scenes but only activate one 0 Answers

LoadLevel easy i know, but not working. 1 Answer

Where is scene data stored? 1 Answer

How do I refer to a .text from a separate scene. 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges