AssetImporter
Provides access to import settings and base functionality for all asset types.
Read time 5 minutesLast updated 5 days ago
Definition
- Type: Class
- Namespace: UnityEditor
- Assembly: UnityEditor.CoreModule
- Inherits from: Object
[ExcludeFromObjectFactory]public class AssetImporter : Object
Remarks
Although this is the base class for all asset importers, the recommended best practice is that you derive from the ScriptedImporter class if you want to write a new, custom importer.
Each asset imported into the project is linked to a corresponding asset importer object. This object provides access to the settings applied during the asset import process. These settings are stored in the file, are located adjacent to the source asset file. They encompass asset bundle information, custom user data, and any external objects upon which the asset relies.
.metaTo obtain the asset importer object associated with an asset, use the AssetImporter.GetAtPath method.
To apply and save any changes made to the settings, use the AssetImporter.SaveAndReimport() method. This action reimports the asset with the updated configuration.
The following example iterates through all assets within the project, identifying those that lack an asset bundle name by examining their respective asset importer objects.
Examples
{code Tests/EditModeAndPlayModeTests/AssetImport/Assets/DocumentationExamples/AssetImport-LogUnbundledAssets.cs}
Properties
Property | Description |
|---|---|
| assetBundleName | Get or set the AssetBundle name. |
| assetBundleVariant | Get or set the AssetBundle variant. |
| assetPath | The path name of the asset for this importer. (Read Only) |
| importSettingsMissing | The value is true when no meta file is provided with the imported asset. |
| userData | Get or set any user data. |
Methods
Method | Description |
|---|---|
| AddRemap | Map a sub-asset from an imported asset (such as an FBX file) to an external Asset of the same type. |
| GetExternalObjectMap | Gets a copy of the external object map used by the AssetImporter. |
| RemoveRemap | Removes an item from the map of external objects. |
| SaveAndReimport | Save asset importer settings if asset importer is dirty. |
| SetAssetBundleNameAndVariant | Set the AssetBundle name and variant. |
| SupportsRemappedAssetType | Checks if the AssetImporter supports remapping the given asset type. |
Static Methods
Method | Description |
|---|---|
| GetAtPath | Retrieves the asset importer for the asset at |
| GetImportLog | Retrieves logs generated during the import of the asset at |
Structs
Struct | Description |
|---|---|
| AssetImporter.SourceAssetIdentifier | Represents a unique identifier for a sub-asset embedded in an imported Asset (such as an FBX file). |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |