Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

AssetDatabase

class in UnityEditor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Description

An Interface for accessing assets and performing operations on assets.

Static Functions

AddObjectToAssetAdds objectToAdd to an existing asset at path.
AssetPathToGUIDGet the GUID for the asset at path.
ClearLabelsRemoves all labels attached to an asset.
ContainsIs object an asset?
CopyAssetDuplicates the asset at path and stores it at newPath.
CreateAssetCreates a new asset at path.
CreateFolderCreate a new folder.
DeleteAssetDeletes the asset file at path.
ExportPackageExports the assets identified by assetPathNames to a unitypackage file in fileName.
FindAssetsSearch the asset database using a search filter string.
GenerateUniqueAssetPathCreates a new unique path for an asset.
GetAllAssetBundleNamesReturn all the AssetBundle names in the asset database.
GetAssetOrScenePathReturns the path name relative to the project folder where the asset is stored.
GetAssetPathReturns the path name relative to the project folder where the asset is stored.
GetAssetPathFromTextMetaFilePathGets the path to the asset file associated with a text .meta file.
GetAssetPathsFromAssetBundleGet the paths of the assets which have been marked with the given assetBundle name.
GetAssetPathsFromAssetBundleAndAssetNameGet the asset paths from the given assetBundle name and asset name.
GetCachedIconRetrieves an icon for the asset at the given asset path.
GetDependenciesGiven an array of pathNames, returns the list of all assets that the assets depend on.
GetLabelsReturns all labels attached to a given asset.
GetSubFoldersGiven an absolute path to a directory, this method will return an array of all it's subdirectories.
GetTextMetaFilePathFromAssetPathGets the path to the text .meta file associated with an asset.
GetUnusedAssetBundleNamesReturn all the unused assetBundle names in the asset database.
GUIDToAssetPathTranslate a GUID to its current asset path.
ImportAssetImport asset at path.
ImportPackageImports package at packagePath into the current project.
IsForeignAssetIs asset a foreign asset?
IsMainAssetIs asset a main asset in the project window?
IsNativeAssetIs asset a native asset?
IsOpenForEditUse IsOpenForEdit to determine if the asset is open for edit by the version control.
IsSubAssetDoes the asset form part of another asset?
IsValidFolderGiven an absolute path to a folder, returns true if it exists, false otherwise.
LoadAllAssetRepresentationsAtPathReturns all asset representations at assetPath.
LoadAllAssetsAtPathReturns an array of all asset objects at assetPath.
LoadAssetAtPathReturns the first asset object of type type at given path assetPath.
LoadMainAssetAtPathReturns the main asset object at assetPath.
MoveAssetMove an asset file from one folder to another.
MoveAssetToTrashMoves the asset at path to the trash.
OpenAssetOpens the asset with associated application.
RefreshImport any changed assets.
RemoveAssetBundleNameRemove the assetBundle name from the asset database. The forceRemove flag is used to indicate if you want to remove it even it's in use.
RemoveUnusedAssetBundleNamesRemove all the unused assetBundle names in the asset database.
RenameAssetRename an asset file.
SaveAssetsWrites all unsaved asset changes to disk.
SetLabelsReplaces that list of labels on an asset.
StartAssetEditingBegin Asset importing. This lets you group several asset imports together into one larger import.
StopAssetEditingStop Asset importing. This lets you group several asset imports together into one larger import.
ValidateMoveAssetChecks if an asset file can be moved from one folder to another. (Without actually moving the file).
WriteImportSettingsIfDirtyWrites the import settings to disk.