Version: 2022.2

EditorSceneManager.sceneManagerSetupRestored

切换到手册

描述

This can be useful to get notified when the SceneManager's scenes are replaced with a set of new scenes from calls to RestoreSceneManagerSetup.

Use the scenes argument to check what scenes has just been opened.

See Also: SceneManagerSetupRestoredCallback.

using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEditor.SceneManagement;

[InitializeOnLoad] class CheckRestoredScenes { static CheckRestoredScenes() { EditorSceneManager.sceneManagerSetupRestored += OnSceneManagerSetupRestored; }

static void OnSceneManagerSetupRestored(Scene[] scenes) { Debug.Log("OnSceneManagerSetupRestored: restored " + scenes.Length); } }