Added support to scan prefabs

This commit is contained in:
Anders Ejlersen 2026-05-19 20:15:30 +02:00
parent 269789b36f
commit 591693da1d
11 changed files with 159 additions and 62 deletions

View file

@ -31,20 +31,21 @@ namespace Module.ProjectValidator.Editor
internal static GUID GetAssetGuid(Object obj)
{
var assetGuid = new GUID();
var assetPath = string.Empty;
if (obj is GameObject gameObject)
{
if (gameObject.scene.isLoaded)
GUID.TryParse(AssetDatabase.AssetPathToGUID(gameObject.scene.path), out assetGuid);
assetPath = gameObject.scene.path;
else if (PrefabUtility.IsPartOfPrefabAsset(gameObject))
GUID.TryParse(AssetDatabase.AssetPathToGUID(gameObject.scene.path), out assetGuid);
assetPath = AssetDatabase.GetAssetPath(gameObject);
}
else
{
GUID.TryParse(AssetDatabase.GetAssetPath(obj), out assetGuid);
assetPath = AssetDatabase.GetAssetPath(obj);
}
GUID.TryParse(AssetDatabase.AssetPathToGUID(assetPath), out var assetGuid);
return assetGuid;
}