title: Why is OnLevelWasLoaded () called twice and why are my variable's values different in each call?
body: <p>I currently have 2 scenes, house scene and overworld scene. Whenever the player enters the house scene, I will save the previous scene with currentArea and position with currentPosition in that scene the player was at. After exiting the house scene, the player will go back to where they last were by checking if the loaded scene's name is currentArea. However, I am currently encountering a problem as I notice that OnLevelWasLoaded() is called twice when a scene is loaded. Furthermore, currentArea will contain the previous scene's data in one call but be empty in another call.</p>
  
  <p>I have tried putting the code in Awake() or Start().</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.SceneManagement;
  
  public class SceneTransition : MonoBehaviour
  {
      public static SceneTransition instance = null;
  
      [SerializeField] string currentArea = "";
      [SerializeField] Vector3 currentPosition;
  
      void Awake()
      {
          if (instance == null)
              instance = this;
          else if (instance != this)
          {
              Destroy(gameObject);
              return;
          }
  
          DontDestroyOnLoad(gameObject);
  
          if (SceneManager.GetActiveScene().name == currentArea)
          {
              BasePlayer.instance.transform.position = currentPosition;
              CameraController.instance.transform.position = new Vector3(currentPosition.x, currentPosition.y, CameraController.instance.transform.position.z);
          }
          else if (GameObject.FindGameObjectWithTag("StartingPoint"))
          {
              BasePlayer.instance.transform.position = GameObject.FindGameObjectWithTag("StartingPoint").transform.position;
              CameraController.instance.transform.position = new Vector3(GameObject.FindGameObjectWithTag("StartingPoint").transform.position.x, GameObject.FindGameObjectWithTag("StartingPoint").transform.position.y, CameraController.instance.transform.position.z);
          }
      }
  
      private void OnLevelWasLoaded(int level)
      {
          if (SceneManager.GetActiveScene().name == currentArea)
          {
             BasePlayer.instance.transform.position = currentPosition;
             CameraController.instance.transform.position = new Vector3(currentPosition.x, currentPosition.y, CameraController.instance.transform.position.z);
          }
          else if (GameObject.FindGameObjectWithTag("StartingPoint"))
          {
              BasePlayer.instance.transform.position = GameObject.FindGameObjectWithTag("StartingPoint").transform.position;
              CameraController.instance.transform.position = new Vector3(GameObject.FindGameObjectWithTag("StartingPoint").transform.position.x, GameObject.FindGameObjectWithTag("StartingPoint").transform.position.y, CameraController.instance.transform.position.z);
          }
      }
  
      public void LoadArea(string nextArea)
      {
          SceneManager.LoadScene(nextArea);
      }
  
      public void LoadEvent(string nextScene)
      {
          SaveCurrentArea();
          SceneManager.LoadScene(nextScene);
      }
  
      public void SaveCurrentArea()
      {
          currentArea = SceneManager.GetActiveScene().name;
          currentPosition = BasePlayer.instance.transform.position;
      }
  
      public void LoadCurrentArea()
      {
          SceneManager.LoadScene(currentArea);
      }
  }
  </code></pre>
  
  <p>I expected currentArea to be the name of the previous area the player was at but it is sometimes null</p>