CodeSmile AssetDatabase 1.10
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 82 of file Asset.File.cs.

83 {
84 try
85 {
86 StartAssetEditing();
87
88 massAssetFileEditAction?.Invoke();
89 }
90 finally
91 {
92 StopAssetEditing();
93 }
94 }

Referenced by Import().

+ Here is the caller graph for this function: