Как узнать индекс сцены unity

от admin

Scene.buildIndex

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Description

Return the index of the Scene in the Build Settings.

Scene.buildIndex varies from zero to the number of Scenes in the Build Settings minus one. This is because indexes start at zero, so the first Scene is at position zero in the buildIndex. For example, five Scenes in the Build Settings have an index from zero to four.

Unity ignores any numbers in a Scene name. For example, if you add a Scene called scene15 to a list of five Scenes in the Build Settings , Unity gives it a buildIndex of 5.

Получение индекса активной сцены в Unity

Необходимо занести индекс активной сцены в переменную i .
Следующий вариант кода выдаёт ошибку.

Как корректно реализовать поставленную задачу (используя SceneManager)?

Т.к. GetActiveScene() возвращает текущий активный на данный момент объект Scene, то вот в нем как раз есть тот самый заветный индекс — Scene.buildIndex. И name тоже, если вдруг понадобится.

Алексей Шиманский's user avatar

Дизайн сайта / логотип © 2023 Stack Exchange Inc; пользовательские материалы лицензированы в соответствии с CC BY-SA . rev 2023.3.13.43306

Нажимая «Принять все файлы cookie» вы соглашаетесь, что Stack Exchange может хранить файлы cookie на вашем устройстве и раскрывать информацию в соответствии с нашей Политикой в отношении файлов cookie.

Как узнать индекс сцены unity

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Читать:
Как скачать origin на макбук

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Description

Return the index of the Scene in the Build Settings.

Scene.buildIndex varies from zero to the number of Scenes in the Build Settings minus one. This is because indexes start at zero, so the first Scene is at position zero in the buildIndex. For example, five Scenes in the Build Settings have an index from zero to four.

Unity ignores any numbers in a Scene name. For example, if you add a Scene called scene15 to a list of five Scenes in the Build Settings , Unity gives it a buildIndex of 5.

Получение индекса активной сцены в Unity

user avatar

user avatar

Всё ещё ищете ответ? Посмотрите другие вопросы с метками c# unity3d или задайте свой вопрос.

Site design / logo © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2022.6.10.42345

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 w$$anonymous$$ch is

although neither attempts are proving successful.

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

Похожие статьи