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

◆ ImportAll()

static void ImportAll ( ImportAssetOptions options = ImportAssetOptions.Default)
static

Scans for external file system modifications and updates the Database accordingly. Prefer to use CodeSmileEditor.Asset.File.Import within CodeSmileEditor.Asset.File.BatchEditing. CAUTION: ImportAll ('Refresh') unloads unused resources. This can degrade editor performance!

For best performance, prefer to use CodeSmileEditor.Asset.File.Import(String[],ImportAssetOptions) to import multiple assets in a batch operation.

When to call ImportAll (same as AssetDatabase.Refresh):

  • After System.IO.File/Directory or similar methods modified files/folders in the project.
  • After running an external process that possibly modified files/folders in the project. There is no need to call ImportAll / 'Refresh' in any other situation!

Modified means the following:

  • Create a file / folder
  • Delete or trash a file / folder
  • Move or rename a file / folder
  • Change a file's contents
  • Change attributes of a file/folder

History: I believe there was a time around Unity 3.x-ish where the Editor did not have an "auto refresh" feature, so calling 'AssetDatabase.Refresh' after any AssetDatabase operation was common. This seems to have stuck, even though it is no longer required. 'Refresh' remains over-used with no thought given to its necessity or performance implications.

Any file operation done VIA the AssetDatabase these days does not require an AssetDatabase refresh! Only file operations that bypass the AssetDatabase require importing affected files. In most cases you know which files are affects, so import them individually. Everyone will thank you for the effort!

CAUTION: Since this method unloads 'unused' assets, any unloaded asset will have to be reloaded when accessed again. Worst case scenario: An editor script that indiscriminately calls this method after common editor operations, such as selection change events, can severely degrade Editor performance!

Further reading for the curious: AssetDatabase Refreshing

Parameters
optionsImportAssetOptions
See also