Hi all. I have game object on my scene, it’s prefab. I want to find it on assets.
I tried to find it, using AssetDatabase.GetAssetPath, but it returns nulls. Here’s the code:
[MenuItem("Custom/Check item")]
private static void CheckSelection()
{
if (Selection.activeGameObject == null) {
Debug.LogError("No item selected");
return;
}
var go = PrefabUtility.FindPrefabRoot(Selection.activeGameObject);
Debug.Log(AssetDatabase.GetAssetPath(go) + " " + AssetDatabase.Contains(go));
}
What’s the right way to find prefab in file system?