How to Customize Importer/Deleter

Updated: 01/30/2020

This page describes the procedure for customizing the Importer/Deleter.
The following explanation is based on the assumption that the project is the same as the project for which the “Import SDK” was performed.

Summary

Importer/Deleter is a function that is called back when an asset with a specified extension is imported or deleted.

To create and customize your own Importer/Deleter, follow these steps.

  1. Create Importer/Deleter scripts that inherit from CubismImporterBase/CubismDeleterBase
  2. Register Importer/Deleter target extensions
  3. Create Import()/Delete() to be called back when imported or deleted

1. Create Importer/Deleter Scripts that Inherit from CubismImporterBase/CubismDeleterBase

Create an ImporterCustomization script.

using Live2D.Cubism.Editor.Importers;

public sealed class ImporterCustomization : CubismImporterBase
{
    /* Omitted */
}
```

Create DeleterCustomization script.

``` C#
using Live2D.Cubism.Editor.Deleters;

public sealed class DeleterCustomization : CubismDeleterBase
{
    /* Omitted */
}

Note: The script is a Unity Editor extension and must be created under the Editor folder.

2. Register Importer/Deleter Target Extensions

Register the extensions of the assets to be processed by the Importer.

public sealed class ImporterCustomization : CubismImporterBase
{
    [UnityEditor.InitializeOnLoadMethod]
    private static void RegisterImporter()
    {
        CubismImporter.RegisterImporter<ImporterCustomization>(".asset");
    }
}

Register the extension of the asset to be processed by the Deleter.

public sealed class ImporterCustomization : CubismImporterBase
{
    [UnityEditor.InitializeOnLoadMethod]
    private static void RegisterDeleter()
    {
        CubismDeleter.RegisterDeleter<DeleterCustomization>(".asset");
    }
}

3. Create Import()/Delete() to Be Called Back when Imported or Deleted

Create an Import() that will be called back when the target assets for Importer processing are imported.

public sealed class ImporterCustomization : CubismImporterBase
{
    public override void Import()
    {
        UnityEngine.Debug.Log("Asset Import as path : " + AssetPath);
    }
}

Create a Delete() that will be called back when the target asset for Deleter processing is deleted.

public sealed class ImporterCustomization : CubismImporterBase
{
    public override void Delete()
    {
        UnityEngine.Debug.Log("Asset deleted as path : " + AssetPath);
    }
}
Please let us know what you think about this article.