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
|
|
@ -178,13 +178,13 @@ namespace Module.ProjectValidator.Editor
|
||||||
var rootObjects = new List<GameObject>();
|
var rootObjects = new List<GameObject>();
|
||||||
|
|
||||||
for (var i = 0; i < assets.Length; i++)
|
for (var i = 0; i < assets.Length; i++)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var assetPath = AssetDatabase.GetAssetPath(assets[i]);
|
var assetPath = AssetDatabase.GetAssetPath(assets[i]);
|
||||||
var scene = SceneManager.GetSceneByPath(assetPath);
|
var scene = SceneManager.GetSceneByPath(assetPath);
|
||||||
var isLoaded = scene.isLoaded;
|
var isLoaded = scene.isLoaded;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!isLoaded)
|
if (!isLoaded)
|
||||||
scene = EditorSceneManager.OpenScene(assetPath, OpenSceneMode.Additive);
|
scene = EditorSceneManager.OpenScene(assetPath, OpenSceneMode.Additive);
|
||||||
|
|
||||||
|
|
@ -194,14 +194,16 @@ namespace Module.ProjectValidator.Editor
|
||||||
{
|
{
|
||||||
ValidateGameObject(rootObjects[j], string.Empty, report, true);
|
ValidateGameObject(rootObjects[j], string.Empty, report, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoaded)
|
|
||||||
EditorSceneManager.CloseScene(scene, true);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.LogException(e);
|
Debug.LogException(e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (!isLoaded && scene.isLoaded)
|
||||||
|
EditorSceneManager.CloseScene(scene, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue