Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

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

Submission failed

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

Close

Cancel

Description

An Interface for accessing assets and performing operations on assets.

Static Properties

Property Description
ActiveRefreshImportModeThe refresh import mode that the Asset Database uses to import assets.
DesiredWorkerCountThe number of import worker processes the asset pipeline aims to maintain during an Asset Database refresh.
GlobalArtifactDependencyVersionChanges during Refresh if anything has changed that can invalidate any artifact.
GlobalArtifactProcessedVersionChanges whenever a new artifact is added to the artifact database.
onImportPackageItemsCompletedCallback raised whenever a package import successfully completes that lists the items selected to be imported.

Static Methods

Method Description
AddObjectToAssetAdds objectToAdd to an existing asset at path.
AllowAutoRefreshDecrements an internal counter which Unity uses to determine whether to allow automatic AssetDatabase refreshing behavior.
AssetPathExistsCheck whether an asset exists at the given path in the database.
AssetPathToGUIDGets the GUID of the asset at a path, including assets deleted in the current Editor session.
CanConnectToCacheServerChecks the availability of the Cache Server.
CanOpenAssetInEditorChecks whether the Unity Editor can open the asset with the specified EntityId.
CanOpenForEditChecks whether an asset object can be opened for editing in version control.
ClearImporterOverrideClears the importer override for the asset.
ClearLabelsRemoves all labels attached to an asset.
CloseCacheServerConnectionCloses an active cache server connection. If no connection is active, then it does nothing.
ContainsChecks whether an object is an asset.
CopyAssetDuplicates the asset at path and stores it at newPath.
CopyAssetsDuplicates assets in paths and stores them in newPaths.
CreateAssetCreates a new asset in a native Unity format.
CreateFolderCreates a new folder, in the specified parent folder.The parent folder string must start with the "Assets" folder, and all folders within the parent folder string must already exist. For example, when specifying "Assets/ParentFolder1/Parentfolder2/", the new folder will be created in "ParentFolder2" only if ParentFolder1 and ParentFolder2 already exist.
DeleteAssetDeletes the specified asset or folder.
DeleteAssetsLets you delete multiple assets or folders at once with performance benefits under version control.
DisallowAutoRefreshIncrements an internal counter which Unity uses to determine whether to allow automatic AssetDatabase refreshing behavior.
EntityIdsToGUIDsConverts a native array of EntityIds to the GUIDs of the matching assets.
ExtractAssetCreates an external Asset from an object (such as a Material) by extracting it from within an imported asset (such as an FBX file).
FindAssetGUIDsSearches the Assets and Packages folders with a filter string, and returns the GUIDs of matching assets.
FindAssetsSearches the Assets and Packages folders with a filter string, and returns the GUIDs, as strings, of matching assets.
ForceReserializeAssetsLoads, upgrades, and writes back to disk every asset in the project.
ForceToDesiredWorkerCountForces the Editor to use the desired amount of worker processes by either spawning new worker processes or shutting down idle worker processes.
GenerateUniqueAssetPathCreates a new unique path for an asset.
GetAllAssetBundleNamesObtain all the AssetBundle names registered in the Asset Database.
GetAssetBundleDependenciesGiven an assetBundleName, returns the list of AssetBundles that it depends on.
GetAssetDependencyHashGets a hash of all the dependencies of the asset at a path.
GetAssetOrScenePathGets the path name relative to the project folder where the asset or scene is stored.
GetAssetPathGets the path of the asset with the specified EntityId, relative to the project folder.
GetAssetPathFromTextMetaFilePathGets the path to the asset file associated with a text .meta file.
GetAssetPathsFromAssetBundleCreates an array containing the paths of all assets marked with the specified AssetBundle name.
GetAssetPathsFromAssetBundleAndAssetNameGet the Asset paths for all Assets tagged with assetBundleName and named assetName.
GetAvailableImportersGets the importer types associated with a given Asset path.
GetCachedIconRetrieves the cached icon for the asset at the given path, without loading the asset. This is the icon shown in the Project window list view.
GetCacheServerAddressGets the IP address of the Cache Server in Editor Settings.
GetCacheServerEnableDownloadGets the Cache Server Download option from Editor Settings.
GetCacheServerEnableUploadGets the Cache Server Upload option from Editor Settings.
GetCacheServerNamespacePrefixGets the Cache Server Namespace prefix set in Editor Settings.
GetCacheServerPortGets the Port number of the Cache Server in Editor Settings.
GetCurrentCacheServerIpGets the IP address of the Cache Server currently in use by the Editor.
GetDefaultImporterReturns the Default Importer associated with the asset located at the supplied path. When no Importer override is set, then the default importer is used. Additional resources: AssetDatabase.GetImporterOverride, AssetDatabase.ClearImporterOverride.
GetDependenciesGets the paths of all the assets that the asset at a path depends on, directly or indirectly.
GetImplicitAssetBundleNameReturns the name of the AssetBundle that a given asset belongs to.
GetImplicitAssetBundleVariantNameReturns the name of the AssetBundle Variant that a given asset belongs to.
GetImporterOverrideReturns the type of the override importer.
GetImporterTypeReturns the type of importer associated with an asset without loading the asset.
GetImporterTypesReturns the types of importers associated with the specified array of assets, without loading those assets.
GetLabelsObtains all labels of a given asset.
GetMainAssetTypeAtPathObtains the type of the main asset object.
GetMainAssetTypeFromGUIDObtains the type of the main object of a given asset.
GetScriptableObjectsWithMissingScriptCountChecks how many unloadable ScriptableObject instances are present in the specified asset.
GetSubFoldersObtains the subdirectories of a given directory in the Assets folder.
GetTextMetaFilePathFromAssetPathGets the path to the text .meta file associated with an asset.
GetTypeFromPathAndFileIDGets an object's type from an Asset path and a local file identifier.
GetUnusedAssetBundleNamesObtains any unused AssetBundle names in the Asset Database.
GUIDFromAssetPathGet the GUID for the asset at path.
GUIDToAssetPathGets the path of the asset with a GUID in string form, relative to the project folder.
ImportAssetImport asset at path.
IsAssetImportWorkerProcessDetermines whether the current process is an Asset Import Worker process.
IsCacheServerEnabledChecks whether the Cache Server is enabled in Project Settings.
IsCacheServerImportResultCachingEnabledChecks whether the Cache Server is configured to enable import result caching. Import result caching is disabled by default for new projects in Unity 6.5. Import result caching can be enabled by passing the command line argument -cacheServerEnableImportResultCaching or setting the environment variable UNITY_CACHE_SERVER_IMPORT_RESULT_CACHING_ENABLED. Projects created prior to Unity 6.5, that are upgraded to Unity 6.5, that have import result caching enabled in Editor Settings or Editor Preferences, will continue to have import result caching enabled.
IsConnectedToCacheServerChecks connection status of the Cache Server.
IsDirectoryMonitoringEnabledReports whether Directory Monitoring is enabled.
IsForeignAssetChecks whether an asset object is a foreign asset, created outside Unity.
IsMainAssetChecks whether an asset object is the main asset of its file in the Project window.
IsMainAssetAtPathLoadedChecks whether the main asset object at assetPath is loaded in memory.
IsMetaFileOpenForEditChecks whether the .meta file of an asset object is open for editing in version control.
IsNativeAssetChecks whether an asset object is a native asset, created by Unity.
IsOpenForEditChecks whether an asset object is open for editing in version control.
IsSubAssetChecks whether an asset object is part of another asset.
IsValidFolderGiven a path to a folder, returns true if it exists, false otherwise.
LoadAllAssetRepresentationsAtPathObtains all sub-assets at assetPath.
LoadAllAssetsAtPathObtains an array of all assets at assetPath.
LoadAssetAtPathRetrieves the first asset object of type type at given path assetPath.
LoadAssetByGUIDLoads an asset object of type type by given GUID assetGUID.
LoadMainAssetAtPathObtains the main asset object at assetPath.
LoadObjectAsyncLoads a specific Object and its dependencies from an Asset file asynchronously.
MakeEditableMakes a file open for editing in version control.
MoveAssetMove an asset file (or folder) from one folder to another.
MoveAssetsToTrashLets you move multiple assets or folders to trash at once with performance benefits under version control.
MoveAssetToTrashMoves the specified asset or folder to the OS trash.
OpenAssetOpens the asset with the specified EntityId in its associated application, optionally at a line.
RefreshImport any changed assets.
RefreshSettingsApply pending Editor Settings changes to the Asset pipeline.
RegisterCustomDependencyAllows you to register a custom dependency that Assets can be dependent on. If you register a custom dependency, and specify that an Asset is dependent on it, then the Asset will get re-imported if the custom dependency changes.
ReleaseCachedFileHandlesCalling this function will release file handles internally cached by Unity. This allows modifying asset or meta files safely thus avoiding potential file sharing IO errors.
RemoveAssetBundleNameRemove the AssetBundle name from the Asset Database.
RemoveObjectFromAssetRemoves object from its asset (Additional resources: AssetDatabase.AddObjectToAsset).
RemoveScriptableObjectsWithMissingScriptRemoves any ScriptableObject instances from the given asset file which cannot be loaded because their scripts could not be found.
RemoveUnusedAssetBundleNamesRemove all the unused AssetBundle names in the Asset Database.
RenameAssetRename an asset file.
ResetCacheServerReconnectTimerResets the internal cache server connection reconnect timer values. The default delay timer value is 1 second, and the max delay value is 5 minutes. Everytime a connection attempt fails it will double the delay timer value, until a maximum time of the max value.
SaveAssetIfDirtyWrites any unsaved changes to an asset object to disk.
SaveAssetsWrites all unsaved asset changes to disk.
SetImporterOverrideSets a specific importer to use for the asset.
SetLabelsReplaces the list of labels on an asset.
SetMainObjectSpecifies which object in the asset file should become the main object after the next import.
StartAssetEditingPauses automatic asset import, allowing you to group several asset imports together into one larger import.
StopAssetEditingEnds the Asset Database's temporary paused state, allowing it to resume normal automatic imports.
TryGetAssetFolderInfoGet AssetDatabase specific information about a folder.
TryGetGUIDAndLocalFileIdentifierGets the GUID and local file identifier of an object, using obsolete parameter types.
UnregisterCustomDependencyPrefixFilterRemoves custom dependencies that match the prefixFilter.
ValidateMoveAssetChecks if an asset file can be moved from one folder to another. (Without actually moving the file).
WriteImportSettingsIfDirtyWrites the import settings to disk.

Events

Event Description
cacheServerConnectionChangedUnity raises this event when Cache Server connection is changed.
importPackageCancelledCallback raised whenever a package import is cancelled by the user.
importPackageCompletedCallback raised whenever a package import successfully completes.
importPackageFailedCallback raised whenever a package import failed.
importPackageStartedCallback raised whenever a package import starts.

Delegates

Delegate Description
ImportPackageCallbackDelegate to be called from AssetDatabase.ImportPackage callbacks.
ImportPackageFailedCallbackDelegate to be called from AssetDatabase.ImportPackage callbacks.