Added support to scan prefabs
This commit is contained in:
parent
269789b36f
commit
591693da1d
11 changed files with 159 additions and 62 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue