using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneLoadDebugger : MonoBehaviour
{
    void Awake()
    {
        DontDestroyOnLoad(gameObject);
        SceneManager.sceneLoaded += OnSceneLoaded;
        SceneManager.sceneUnloaded += OnSceneUnloaded;
    }

    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        Debug.Log($">>> SCENE LOADED: {scene.name} (mode: {mode})\n{System.Environment.StackTrace}");
    }

    void OnSceneUnloaded(Scene scene)
    {
        Debug.Log($"<<< SCENE UNLOADED: {scene.name}\n{System.Environment.StackTrace}");
    }

    void OnDestroy()
    {
        SceneManager.sceneLoaded -= OnSceneLoaded;
        SceneManager.sceneUnloaded -= OnSceneUnloaded;
    }
}