Question:
Good evening!
It is necessary to put the index of the active scene in the variable i
.
The next code variant throws an error.
using ...
using UnityEngine.SceneManagement;
byte i;
i = (byte)(SceneManager.sceneLoaded());
How to correctly implement the task (using SceneManager)?
Answer:
You need this:
SceneManager.GetActiveScene().buildIndex;
Because GetActiveScene()
returns the currently active Scene object, then it contains the very cherished index – Scene.buildIndex . And name
too, if you suddenly need it.