Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AssetImporter

Provides access to import settings and base functionality for all asset types.
Read time 5 minutesLast updated 4 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
.meta
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.
To 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

assetBundleNameGet or set the AssetBundle name.
assetBundleVariantGet or set the AssetBundle variant.
assetPathThe path name of the asset for this importer. (Read Only)
importSettingsMissingThe value is true when no meta file is provided with the imported asset.
userDataGet or set any user data.

Methods

Method

Description

AddRemapMap a sub-asset from an imported asset (such as an FBX file) to an external Asset of the same type.
GetExternalObjectMapGets a copy of the external object map used by the AssetImporter.
RemoveRemapRemoves an item from the map of external objects.
SaveAndReimportSave asset importer settings if asset importer is dirty.
SetAssetBundleNameAndVariantSet the AssetBundle name and variant.
SupportsRemappedAssetTypeChecks if the AssetImporter supports remapping the given asset type.

Static Methods

Method

Description

GetAtPathRetrieves the asset importer for the asset at
path
.
GetImportLogRetrieves logs generated during the import of the asset at
path
.

Structs

Struct

Description

AssetImporter.SourceAssetIdentifierRepresents a unique identifier for a sub-asset embedded in an imported Asset (such as an FBX file).

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.