unity on scene load code example

Example 1: unity scene load

using UnityEngine.SceneManagement;

//Put this in whenever you want to load a scene
SceneManager.LoadScene("Scene name");

Example 2: unity method on scene loaded

using UnityEngine;
using UnityEngine.SceneManagement;
public class ExampleCode : MonoBehaviour
{
    // called zero
    void Awake()
    {
        Debug.Log("Awake");
    }    
    
    // called first
    void OnEnable()
    {
        Debug.Log("OnEnable called");
        SceneManager.sceneLoaded += OnSceneLoaded;
    }    
    
    // called second
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        Debug.Log("OnSceneLoaded: " + scene.name);
        Debug.Log(mode);
    }    
    
    // called third
    void Start()
    {
        Debug.Log("Start");
    }    
    
    // called when the game is terminated
    void OnDisable()
    {
        Debug.Log("OnDisable");
        SceneManager.sceneLoaded -= OnSceneLoaded;
    }
}