docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ModularImporter

    Abstract base class for custom asset importer using an ImporterGraph.

    Modular importers are scripts that are associated with specific file extensions. They are invoked by Unity's Asset pipeline to convert the contents of associated files into Assets. Use the ScriptedImporterAttribute class to register custom importers with the Asset pipeline.

    Inheritance
    object
    Object
    AssetImporter
    ScriptedImporter
    ModularImporter
    UsdModularImporter
    Inherited Members
    ScriptedImporter.SupportsRemappedAssetType(Type)
    AssetImporter.GetImportLog(string)
    AssetImporter.SetAssetBundleNameAndVariant(string, string)
    AssetImporter.GetAtPath(string)
    AssetImporter.SaveAndReimport()
    AssetImporter.AddRemap(AssetImporter.SourceAssetIdentifier, Object)
    AssetImporter.RemoveRemap(AssetImporter.SourceAssetIdentifier)
    AssetImporter.GetExternalObjectMap()
    AssetImporter.assetPath
    AssetImporter.importSettingsMissing
    AssetImporter.assetTimeStamp
    AssetImporter.userData
    AssetImporter.assetBundleName
    AssetImporter.assetBundleVariant
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: UnityEditor.Importer
    Assembly: Unity.Importer.Editor.dll
    Syntax
    public abstract class ModularImporter : ScriptedImporter

    Properties

    DefaultGraphPath

    A project path where the default ImporterGraph to use when the asset is imported for the first time and no graph is set yet.

    Declaration
    protected virtual string DefaultGraphPath { get; }
    Property Value
    Type Description
    string
    Examples
    using UnityEditor.Importer;
    [ModularImporter(version: 1, ext: "sphere")]
    public class SphereImporter : ModularImporter
    {
        protected override ImporterGraph DefaultGraphPath => "Assets/DefaultImporters/SphereImporter.asset";
    }

    ErrorIdsToTrack

    A set of ids to track for analytics. Error id 0 is reserved for exception, and error id 1 is reserved for errors from GetAnalyticsData.

    Declaration
    protected virtual HashSet<int> ErrorIdsToTrack { get; }
    Property Value
    Type Description
    HashSet<int>

    Graph

    The ImporterGraph used by the ModularImporter to convert the content of this file into Unity's assets.

    Declaration
    public LazyLoadReference<ImporterGraph> Graph { get; set; }
    Property Value
    Type Description
    LazyLoadReference<ImporterGraph>

    ImportSettingOverrides

    The import setting overrides declared for this importer.

    Declaration
    public IReadOnlyList<IGraphValue> ImportSettingOverrides { get; }
    Property Value
    Type Description
    IReadOnlyList<IGraphValue>

    WarningIdsToTrack

    A set of warning ids to track for analytics.

    Declaration
    protected virtual HashSet<int> WarningIdsToTrack { get; }
    Property Value
    Type Description
    HashSet<int>

    Methods

    AddImportSettingOverride(IGraphValue)

    Add an ImportSetting<T> to the import setting overrides.

    Declaration
    public ModularImporterValidationResult AddImportSettingOverride(IGraphValue setting)
    Parameters
    Type Name Description
    IGraphValue setting

    An ImportSetting<T> to add.

    Returns
    Type Description
    ModularImporterValidationResult

    The ModularImporterValidationResult of this command.

    OnFinishingAssetImport(GraphLogger)

    This method is called at the end of the import.

    Declaration
    protected virtual void OnFinishingAssetImport(GraphLogger graphLogger)
    Parameters
    Type Name Description
    GraphLogger graphLogger

    The graph logger.

    OnImportAsset(AssetImportContext)

    This method is called by the Asset pipeline to import files.

    Declaration
    public override void OnImportAsset(AssetImportContext ctx)
    Parameters
    Type Name Description
    AssetImportContext ctx

    This argument contains all the contextual information needed to process the import event and is also used by the custom importer to store the resulting Unity Asset.

    Overrides
    ScriptedImporter.OnImportAsset(AssetImportContext)
    Remarks

    It is already implemented by the ModularImporter class to validate and execute the Graph. If the import is successful, this method will call ProcessImportResult(IReadOnlyList<IGraphValue>, AssetImportContext) with the result of the graph execution.

    ProcessImportResult(IReadOnlyList<IGraphValue>, AssetImportContext)

    This method is called at the end of the import if the Graph execution was a success.

    Declaration
    protected virtual void ProcessImportResult(IReadOnlyList<IGraphValue> results, AssetImportContext ctx)
    Parameters
    Type Name Description
    IReadOnlyList<IGraphValue> results

    A readonly list of ImportResult<T> that get generated from the Graph execution.

    AssetImportContext ctx

    This argument contains all the contextual information needed to process the import event and is also used by the custom importer to store the resulting Unity Asset.

    Remarks

    The default implementation looks for Object to add them in the AssetImportContext as resulting assets of the import. The following ImportResult<T> types are supported:

    • Object
    • Object[]
    • List<Object>
    • Dictionary<string, Object>

    RemoveImportSettingOverride(IGraphValue)

    Remove an ImportSetting<T> from the import setting overrides.

    Declaration
    public ModularImporterValidationResult RemoveImportSettingOverride(IGraphValue setting)
    Parameters
    Type Name Description
    IGraphValue setting

    An ImportSetting<T> to remove.

    Returns
    Type Description
    ModularImporterValidationResult

    The ModularImporterValidationResult of this command.

    Validate()

    Validate this ModularImporter.

    Declaration
    public ModularImporterValidationResult Validate()
    Returns
    Type Description
    ModularImporterValidationResult

    The ModularImporterValidationResult of this validation.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)