スクリプト
using System.Linq;
using UnityEditor;
using UnityEngine;
internal static class Example
{
[MenuItem( "Tools/Hoge" )]
private static void Hoge()
{
const string directoryName = "Assets/";
var assetPaths = AssetDatabase
.GetAllAssetPaths()
.Where( x => x.StartsWith( directoryName ) )
.Where( x => AssetDatabase.LoadAssetAtPath<GameObject>( x ) != null )
.ToArray()
;
try
{
AssetDatabase.StartAssetEditing();
foreach ( var assetPath in assetPaths )
{
using var editingScope = new PrefabUtility.EditPrefabContentsScope( assetPath );
var prefabRoot = editingScope.prefabContentsRoot;
var transforms = prefabRoot.GetComponentsInChildren<Transform>();
if ( transforms.Length <= 0 ) continue;
TODO
}
}
finally
{
AssetDatabase.StopAssetEditing();
}
}
}