Quick answer: Wrap bulk asset creation in StartAssetEditing/StopAssetEditing. Avoid Refresh from per-frame editor code. Use ImportAsset for specific files instead of full refresh.
An editor tool generates 200 ScriptableObject assets. After each CreateAsset, you call AssetDatabase.Refresh. The tool takes 90 seconds and the editor is frozen the whole time. Single batched refresh would do it in 2 seconds.
Batch with Start/Stop
AssetDatabase.StartAssetEditing();
try {
for (int i = 0; i < 200; i++) {
var obj = ScriptableObject.CreateInstance<MyAsset>();
AssetDatabase.CreateAsset(obj, $"Assets/Generated/Asset_{i}.asset");
}
} finally {
AssetDatabase.StopAssetEditing();
AssetDatabase.SaveAssets();
}
Start/Stop pauses asset import processing. Inside the block, CreateAsset queues but doesn’t trigger import. StopAssetEditing flushes the queue, importing everything once. 50× faster than per-asset refresh.
Use ImportAsset for Targeted Updates
// When you know exactly which file changed
AssetDatabase.ImportAsset("Assets/Levels/level1.asset");
Reimports just one asset. Faster than Refresh which scans everything. Use whenever you know the modified path.
Avoid Per-Frame Refresh
Some editor tools call Refresh from EditorApplication.update. Don’t. Refresh is heavy; calling it 60 times a second freezes Unity. Trigger Refresh only on user actions or external file change events.
External File Watcher
For tools that watch external folders (e.g., a Tiled file outside Assets/), use System.IO.FileSystemWatcher and call ImportAsset only when a target file changes — not on every Refresh cycle.
SaveAssets for Persistence
StopAssetEditing imports but doesn’t necessarily save the .asset to disk. Call AssetDatabase.SaveAssets() after — ensures changes survive editor crash.
Verifying
Profile the editor tool. Before fix: 200 individual Refresh calls dominate the timeline. After: a single import burst at StopAssetEditing. Total runtime drops dramatically.
“Refresh is a hammer; ImportAsset is a scalpel. Batch with Start/Stop and only Refresh when truly needed.”
For editor tools generating many assets, batching is the single biggest perf win — minutes become seconds.