1
\$\begingroup\$

I've created an importer for Aseprite-Files with the ScriptedImporter classes. I'm working on supporting the latest features of Unity like the secondary texture and this should work without bigger issues.

The current issue I'm facing is when I change the sprites in the Sprite Editor or from a feature of my own, the asset won't get changed in the project-window unless i switch to another folder and switch back.

Do I have something wrong in my importing order or is something missing? I tried to refresh or reload the asset in the AssetDatabase but that didn't worked.

The OnImportAsset method looks like the following. I implemented the ISpriteEditorDataProvider to support the sprite-editor.

    public override void OnImportAsset(AssetImportContext ctx)
    {
        name = GetFileName(assetPath);
        _aseFile = ReadAseFile(assetPath);

        GenerateAtlasTexture();

        if (spriteImportData == null || spriteImportData.Length == 0)
        {
            SetSingleSpriteImportData();
        }

        GenerateTexture(ctx.assetPath);

        ctx.AddObjectToAsset("Texture", texture);
        ctx.SetMainObject(texture);

        foreach (Sprite sprite in sprites)
        {
            ctx.AddObjectToAsset(sprite.name, sprite);
        }
    }

With the GenerateAtlasTexture method I create a sprite-atlas out of the aseprite-file.

I had to create my own SpriteImportData class because Unitys struct won't get stored through the serialization process and I have to store the import settings of each sprite in a way.

The GenerateTexture method uses Unitys own TextureGenerator class to generate the textures or sprites and store them in a instance-variable called sprites.

Here is the link to the repo. It is currently in the "sprite-editor" branch. https://github.com/martinhodler/unity-aseprite-importer/tree/sprite-editor

Thanks a lot

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.