Unity C#
Trying to close a scene from the Hierarchy when a user clicks play in the editor. It returns True but the scene remains open.
[InitializeOnLoad]
class EditorClass : Editor{
static EditorClass(){
//user clicks play
if (EditorApplication.isPlayingOrWillChangePlaymode) {
//remove a scene
Debug.Log(EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByName(sceneName),false));
}
}
}