Been trying to do this one lately... Hope this helps :<
Here's the code for getting the current scene, I put in on my go to another scene button.
public void goToScene(string scene)
{
SceneManager.LoadScene (scene);
var currentScene = SceneManager.GetActiveScene();
var currentSceneName = currentScene.name;
gotoPreviousScreen.previousScene = currentSceneName;
Debug.Log(currentSceneName);
}
Here's the code to go to the previous scene
public void goToScene(string scene)
{
SceneManager.LoadScene (scene);
var currentScene = SceneManager.GetActiveScene();
var currentSceneName = currentScene.name;
gotoPreviousScreen.previousScene = currentSceneName;
Debug.Log(currentSceneName);
}
And this is the code where I save the scenes, which I later call
public static string previousScene;
public static bool getScene { get { return previousScene != null; } }