CodeSmile AssetDatabase 1.9
Unity's AssetDatabase in enjoyable, consistent, concise, convenient, comprehensible, safe, documented form.
Loading...
Searching...
No Matches

◆ BatchEditing()

static void BatchEditing ( [NotNull] Action massAssetFileEditAction)
static

Batch multiple asset file operations to improve execution speed.

Within the massAssetFileEditAction the AssetDatabase will queue any CodeSmileEditor.Asset.File operations and runs them afterwards in a single refresh cycle. This can significantly speed up mass file operations.

The callback Action is safeguarded against exceptions leaving the AssetDatabase in a 'suspended' state. Also note that Allow.. and DisallowAutoRefresh calls are already implied when using Start/StopAssetEditing. See the code snippet below for implementation details.

CAUTION:

  • Importing an asset and subsequently trying to load the asset within the callback will return null.
  • For that reason you cannot create new Asset instances or call methods that create Asset instances, such as Copy, during batch editing.
  • When 'externally' modifying files and importing those, consider the above implication. You need to defer loading and working with these objects. Calling BatchEditing twice is good practice (first modify & import, then load the assets).
Parameters
massAssetFileEditActionWrite any mass file editing code in this action.
See also

Definition at line 77 of file Asset.File.cs.

78 {
79 try
80 {
81 StartAssetEditing();
82
83 massAssetFileEditAction?.Invoke();
84 }
85 finally
86 {
87 StopAssetEditing();
88 }
89 }