check if you are in a scene unity code example Example: unity how to get the current scene SceneManager.GetActiveScene().buildIndex;