Validator: Fixed issue, where scene wouldn't unload, if an exception is thrown
This commit is contained in:
parent
3802ca557c
commit
9dd45f536e
1 changed files with 9 additions and 7 deletions
|
|
@ -179,12 +179,12 @@ namespace Module.ProjectValidator.Editor
|
|||
|
||||
for (var i = 0; i < assets.Length; i++)
|
||||
{
|
||||
var assetPath = AssetDatabase.GetAssetPath(assets[i]);
|
||||
var scene = SceneManager.GetSceneByPath(assetPath);
|
||||
var isLoaded = scene.isLoaded;
|
||||
|
||||
try
|
||||
{
|
||||
var assetPath = AssetDatabase.GetAssetPath(assets[i]);
|
||||
var scene = SceneManager.GetSceneByPath(assetPath);
|
||||
var isLoaded = scene.isLoaded;
|
||||
|
||||
if (!isLoaded)
|
||||
scene = EditorSceneManager.OpenScene(assetPath, OpenSceneMode.Additive);
|
||||
|
||||
|
|
@ -194,14 +194,16 @@ namespace Module.ProjectValidator.Editor
|
|||
{
|
||||
ValidateGameObject(rootObjects[j], string.Empty, report, true);
|
||||
}
|
||||
|
||||
if (!isLoaded)
|
||||
EditorSceneManager.CloseScene(scene, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!isLoaded && scene.isLoaded)
|
||||
EditorSceneManager.CloseScene(scene, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue