AssetDatabase
Scripting > Editor Classes > AssetDatabase
AssetDatabase Class

An Interface for accessing assets and performing operations on assets.

Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.

Class Functions
Contains

Is object an asset?

IsMainAsset

Is asset a main asset in the project window?

GenerateUniqueAssetPath

Creates a new unique path for an asset.

StartAssetEditing

Begin Asset importing. This lets you group several asset imports together into one larger import.

StopAssetEditing

Stop Asset importing. This lets you group several asset imports together into one larger import.

ValidateMoveAsset

Checks if an asset file can be moved from one folder to another. (Without actually moving the file)

MoveAsset

Move an asset file from one folder to another.

RenameAsset

Rename an asset file.

MoveAssetToTrash

Moves the asset at path to the trash.

DeleteAsset

Deletes the asset file at path.

ImportAsset

Import asset at path.

CopyAsset

Duplicates the asset at path and stores it at newPath

CreateAsset

Creates a new asset at path.

AddObjectToAsset

Adds objectToAdd to an existing asset at path.

GetAssetPath

Returns the path name relative to the project folder where the asset is stored

LoadAssetAtPath

Returns the asset at the given path if it inherits from type.

LoadMainAssetAtPath

Returns the main asset at assetPath.

LoadAllAssetsAtPath

Returns an array of all asset objects at assetPath.

Refresh

Import any changed assets.

OpenAsset

Opens the asset with associated application.

AssetPathToGUID

Get the GUID for the asset at path

GUIDToAssetPath

Translate a GUID to its current asset path

SaveAssets

Writes all unsaved asset changes to disk.

GetCachedIcon

Retrieves an icon for the asset at the given asset path.