Git Product home page Git Product logo

unity-aseprite-importer's Introduction

Aseprite-Importer for Unity

AsepriteImporter Thumbnail

openupm

This package helps you importing .ase files from aseprite. The reader is fully written in C# which reads the compressed binary file and creates spritesheets, sprites and animations out of it.

Features

  • Creates a sprite sheet file (not dynamic)
  • Editable meta data like custom physics shapes with the 'Sprite Editor'
  • Generates tilemap with extended-padding (solves lines tearing issue between tiles)
  • Makes animation files (not dynamic)
  • Creates an animation controller
  • New tilemap name rule support (row-col)

Demo GIF of AsepriteImporter

image image image

Install

OpenUPM

Unity Package

OpenUPM lets you install packages more easily by providing a downloadable unity package which will setup the package automatically. You can find the download on the following link:

openupm https://openupm.com/packages/io.tinu.asepriteimporter/

CLI

Prerequisites

See: https://openupm.com/docs/getting-started.html#installing-openupm-cli

OpenUPM CLI Install
# Go to your Unity project directory
cd YOUR_UNITY_PROJECT_DIR

# Install package: io.tinu.asepriteimporter
openupm add io.tinu.asepriteimporter

Unity

  • In Unity open the Package Manager (Window > Package Manager).
  • In the Package Manager click on the Plus-Icon in the top-left and select Add package from git URL...
  • Enter the URL of this Repository (https://github.com/martinhodler/unity-aseprite-importer.git) and press Enter

License

See LICENSE file.

Note: As of Unity doesn't include any editor scripts in the game, you don't have to license your game under GPL.

unity-aseprite-importer's People

Contributors

advra avatar alansikora avatar alexdavies8 avatar alexpennells avatar ceejayzsmith avatar chris-janidlo avatar dssdiego avatar exanite avatar martinhodler avatar mjshin82 avatar norcrel avatar p10tr3k avatar rlapostolle avatar whoozi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-aseprite-importer's Issues

Image embedded data

It would be nice I was able to embed data into the image itself, similar to how MetaSprite does it:
https://github.com/WeAthFoLD/MetaSprite/wiki/Metadata

Specifically...

  • Add a layer in aseprite with a special name (ie. #pivot) where you can draw the pivot point for each sprite.
  • Add a layer in aseprite with a special name (ie. //whatever) where you can draw whatever without it getting imported.
  • Add a special tag attribute to each tag to indicate a looping animation (ie. TagNameExample #loop)

MetaSprite has a few more, but for now, these would be great timesavers and painkillers.

License question

If I am correct any product containing a library with a GPL license should have open sources and be a GPL compatible. If my understanding is correct the Unity assemble will contain some parts of this importer which is basically legally forcing every project to share sources under GPL-compatible license.

The question is: Why not MIT?

Images on UI requires to check Use Sprite Mesh

Describe the bug
Images on UI requires to check Use Sprite Mesh to be fully rendered.
I don't really know if it is bug or feature :) But png doesn't require this and images imported form Aseprite do.

To Reproduce
On canvas add Image and use image imported with Aseprite. The sprite is rendered in 1/4. You have to check Use Sprite Mesh to see it fully rendered

Screenshots
When Use Sprite Mesh is off
image
When Use Sprite Mesh is on
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Version 2020.2.1f1

Problem when changing frame order in Aseprite file

I found a weird bug when I tried to move a frame in the Aseprite file.
I've created an empty frame and moved to be the first. After saving the file and got back to Unity, I checked the png generated from the Aseprite file and noticed that now the last sprite isn't selected. Also, after doing that, in the Sprite Atlas file of the png, all the sprites created are now duplicated.
Here some screenshots to make the problem more clear:

image
Here in the first image the frame I've moved.

image
And now here the png after I've moved that sprite. As you notice, the last sprite isn't selected

image
In the Sprite Atlas of the png, now all the sprites are duplicated.

Hope you'll fix the problem, thanks.

Custom Outline option not working in Bundle version

When I try to select the Custom Outline option of the Sprite Editor in the Bundle Version, it generates a bunch of errors and doesn't load the editor:

image
These errors seem to appear every frame till I close the window

image

I know that the Bundle Version is still in preview and isn't ready, but I just wanted to point out this bug and hope you'll fix it. I love this importer, but I think that having subfolders for each Aseprite file is kind of bulky.
Thanks.

I'm using the 1.0.4 version in Unity 2019.4.19f1

adding package fails

Upon adding the package git URL in the package manager on a brand new project (and fresh Unity install), it appears to fail to import, as the package itself is empty.

Here is the error message and the inspector on the package. It's still visible in my packages for the project, it just doesn't do anything.

image

image

Loop Animation Option not being applied

Describe the bug
Toggling the loop option on an animation gets ignored. Toggle works ok, but when applying the value always resets to true for the created animation clip

To Reproduce
Steps to reproduce the behavior:

  1. Import .aseprite file
  2. Uncheck Loop in the Animation Options on a single animation
  3. Click Apply
  4. View the created animation clip in the Project view. Loop Time is always set to true

Expected behavior
Loop Time should be set to false for the created animation clip

Screenshots
Screen Shot 2019-11-19 at 8 09 56 PM
Screen Shot 2019-11-19 at 8 10 19 PM

Desktop (please complete the following information):

  • MacOS Mojave 10.14.5
  • Unity 2019.2.12f1

Error in GetTextureFromCel (#16) May not have been fixed correctly.

I made a sprite is aseprite with some pixels that were out of the canvas, in the bottom left corner.
I wasn't able to import that sprite.

Unity gives me the same error messages mentioned in this issue;
#16

From what I've seen, the issue may have not been fixed correctly.
I think I've resolved the issue using the following code.

The current code (256, AseFile.cs)
`for(int y = 0; y < renderRectHeight; y++) {
for(int x = 0; x < renderRectWidth; x++) {
int celDataIndex = (y + celY) * cel.Width + (x + celX);
int index = (renderRectHeight - 1 - (y)) * renderRectWidth + (x);

    // The celDataIndex is out of range when celX or celY is > 0.
    colors[index] = cel.RawPixelData[celDataIndex].GetColor();
}

}`

My temporary patch
`for(int y = 0; y < renderRectHeight; y++) {
for(int x = 0; x < renderRectWidth; x++) {
// The cel can't be sampled out of bounds in case celX/celY + x/y is bigger than the cel size
if((x + celX) >= cel.Width) {
continue;
}
if((y + celY) >= cel.Height) {
continue;
}
int celDataIndex = (y + celY) * cel.Width + (x + celX);
int index = (renderRectHeight - 1 - (y)) * renderRectWidth + (x);

    colors[index] = cel.RawPixelData[celDataIndex].GetColor();
}

}`

The file that causes the error:
Player_Jump.zip

unity-aseprite-importer generates tons of garbage in RAM

Hi! I've found that your importer may generate a lot of garbage in RAM.

You can try loading the small demo image attached (256x256 px) and check Unity's Profiler. Here is a screenshot where new AseFile(stream); takes more that 1 GB RAM when loading it.
image

Another issues that I've found that you create temp textures and leave them in RAM. For example, here is your GetFrame(int index) method where Texture2DBlender generates new textures. I've made a workaround with destroying textures:
image

Demo project: https://drive.google.com/file/d/147BEdQGPhsTpYh54UNZlx5C5zPCbWrV-/view?usp=sharing

Project is incompatible with Unity Package Manager

The project can not be imported using the unity package manager as there are no meta files.

Steps To Reproduce

  1. Add
    "io.tinu.asepriteimporter": "https://github.com/martinhodler/unity-aseprite-importer.git#master"
    to the dependecies in UNITY_PROJECT_FOLDER\Packages\manifest.json
  2. Open the Unity Project
  3. View the errors in the console
  4. View that the importer does not work because of the missing files.

Expected behavior
No errors and the files should be visible under the Packages folder in the Unity project window.

Screenshots
erroraseprite

Desktop (please complete the following information):

  • OS: Windows
  • Version: 2019.3.0f5

Additional context
I propose the .meta files be generated and added to the git repo. This would also help with version control, if users do not use the package manager, and using this importer between projects (as the references could be different).

Export layers as separate sprite sheets.

Is your feature request related to a problem? Please describe.
My game uses a paper doll system to use weapons and armor, and would like for the importer to be able to handle importing of a single file with paper doll layers so that I can do all my animation in a single aseprite file for easy editing and updating.

Describe the solution you'd like
There would be a checkbox on the importer that would be like "export layers as separate sprites" and checking the box and re-importing would have a sprite sheet per layer.
image

Describe alternatives you've considered
I guess the alternative would just be having to manually exporting the animations from aseprite, or like figuring out how to write a lua script to export each layer and animation tag as it's own sprite sheet and then manually slicing and creating all the animations in unity by hand.

Additional context
In this example I have an attack right tag, and I have a Player Hammer and Sword layers, but when using the unity aseprite importer, these layers are flattened into a single sprite per frame causing the sword and hammer to be visible at the same time, I'd like for the player, hammer, and sword layers to be separate sprite sheets/animations

image

So if it's Player.ase then it would export the images and animations like:

Player/Player_Sword.png
Player/Player_Sword_Attack_Down.anim
Player/Player_Sword_Attack_Left.anim
Player/Player_Sword_Attack_Right.anim
Player/Player_Sword_Attack_Up.anim

Player/Player_Hammer.png
Player/Player_Hammer_Attack_Down.anim
Player/Player_Hammer_Attack_Left.anim
Player/Player_Hammer_Attack_Right.anim
Player/Player_Hammer_Attack_Up.anim

Player/Player_Player.png
Player/Player_Player_Attack_Down.anim
Player/Player_Player_Attack_Left.anim
Player/Player_Player_Attack_Right.anim
Player/Player_Player_Attack_Up.anim

Multi-row Atlas

The importer does only create a spritesheet with every sprite behind the next. The sprites should be arranged evenly over columns and rows.

Tileset Options wont slice up sprite sheet

Hey there! when I change the values under "TilesetOptions" the image does not get sliced when set to import type "Tileset"

I have a sprite sheet I would like to slice up (like Unity does) with 16x16 cells. is this possible? its not an animation, they are different sprites per cell.

Linked frames are imported as blank sprites

Bug
When importing an animation with linked frames, the link's frames after the 1st instance are imported as blank sprites. In other words, for any set of linked frames, the artwork is only present in the first frame of the set.

To Reproduce

  1. In Aseprite, create an animation with linked frames.
  2. Save the file as .aseprite and import it to Unity with the package present.
  3. Examine the generated sprites and animation. Linked frames after the 1st are blank.

Expected behavior
I expect all linked frames in the generated animation to display the same artwork as they do in Aseprite. I also expect to see the animation re-use the same sprite asset for a set of linked frames, instead of generating a duplicate asset for each frame.

Screenshots
Screen Shot 2019-05-09 at 3 18 39 PM

Desktop (please complete the following information):

  • OS: OSX
  • Version 2019.1

Error in GetTextureFromCel

Describe the bug
When importing a file I get an error within GetTextureFromCel() of AseFile.cs. Here is the traceback in Unity:

Aseprite.AseFile.GetTextureFromCel (Aseprite.Chunks.CelChunk cel) (at Assets/unity-aseprite-importer/Editor/Aseprite/AseFile.cs:238)
Aseprite.AseFile.GetFrame (Int32 index) (at Assets/unity-aseprite-importer/Editor/Aseprite/AseFile.cs:174)
Aseprite.AseFile.GetFrames () (at Assets/unity-aseprite-importer/Editor/Aseprite/AseFile.cs:53)
AsepriteImporter.AseFileImporter.OnImportAsset (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at Assets/unity-aseprite-importer/Editor/AseFileImporter.cs:38)
UnityEditor.Experimental.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at C:/buildslave/unity/build/Editor/Mono/AssetPipeline/ScriptedImporter.cs:19)

The culprit seems to be this line:
colors[index] = cel.RawPixelData[celDataIndex].GetColor();

Here is a snippet of some print statements checking index and celDataIndex.
image

Im not entirely sure what the functions intended purpose is so it is difficult to determine what it does. "render as large as the viewport". Is this the viewport to preview a sprite in the box at the bottom of the inspector or is it within game?

** Steps to Reproduce**
Importing this attached aesprite image will break the code described above.
SpriteColoImportError.zip

Desktop (please complete the following information):

  • OS: Windows 10

Support .aseprite file extension

Is your feature request related to a problem? Please describe.
Seems like only .ase files are recognized for import. Asperite has since moved to using .asperite extension to avoid conflicts with some other file types that were already using it.

Describe the solution you'd like
Import recognizes .asperite files and imports the same way.

Describe alternatives you've considered
I guess grumping it up and just reminding myself to select the .ase extension.

Additional context
I think it's fairly self explanatory. I imagine it would be a low effort change.

Ase file incorrect size detected

Describe the bug
For attached file which size is 224x240, importer detects size 512x512. The image is incorrectly imported.
Importer: Bundled (preview)

To Reproduce
Just import attached file

Screenshots
This image
image
is imported like this
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Version 2020.1.4f1

test.zip

FPS drops to 4 in 3d URP Project

Describe the bug
When importing this package if it's a 3D project and there is a terrain background and SpriteRender is on top of image FPS drops to 4 every few second. (Even if not using the package)

To Reproduce
Steps to reproduce the behavior:

  1. Just import the package in 3D URP
  2. Place 2 sprites on top of terrain
  3. See the FPS Drop if you move around.

Expected behavior
FPS not to Drop

Screenshots
Without Package:
https://github.com/martinhodler/unity-aseprite-importer/assets/63500913/90e57a56-59bd-4eba-9913-122e1951c721

Importing Package
https://github.com/martinhodler/unity-aseprite-importer/assets/63500913/dd5bd972-9eef-4817-ac55-cc4f9b46e5b5

After Importing and doing no change, What's so ever
https://github.com/martinhodler/unity-aseprite-importer/assets/63500913/d947d016-71c7-404a-9f7d-e3ccfd58ea91

Desktop (please complete the following information):

  • OS: Windows 11
  • Version 2022.3.7f1

Additional context
I have deleted a full project, not being able to find out why. Then for no reason After Importing ALL 2d Package for Sprite Editor I get the same problem.

Cannot set borders in sprite from aseprite

Describe the bug
Normally I can set borders in Unity sprite editor, but when sprite is imported from aseprite file, borders are reset when apply button is pressed.

Expected behavior
Allow setting borders in sprites imported with this extension.

Desktop (please complete the following information):

  • OS: Windows 10
  • Version 2020.2.1f1

Transparency Color sprite property not respected in Indexed color mode

Describe the bug
If I import an indexed color mode aseprite file where the color referenced by the Transparent Color setting is not transparent, the importer ignores the Transparent Color setting and instead fills the background with the color at that index.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new aseprite file with indexed color mode (the default color has solid black as index 0, but also sets the Transparent Color sprite property to index 0).
  2. Add a stroke of a different color to the canvas (leaving some areas of the canvas blank)
  3. Import the ase file in Unity and look at it
  4. Observe that the background within the x and y bounds of the stroke on the canvas is now black rather than transparent.

Expected behavior
The aseprite importer should respect the "Transparent Color" sprite property in indexed color mode, and instead of filling with the index color, fills it with transparent.

My current workarounds: Set the color of the transparent color index to transparent. Set the color of the transparent color index to a color I don't expect to use then use mask transparency mode in the importer. These kinds of workarounds feel like they should be unnecessary.

Screenshots
asefile
settings
Indexed Color mode:
bad
RGB Color mode:
good(rgb mode)

Desktop (please complete the following information):

  • OS: Windows 11
  • Unity 2020.3.21f

Additional context

The file I'm testing with:
Enemy.zip

tests

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Slice support

It would be nice to have support for slices to be imported as separate sprites (with correct 9-slicing and pivots). Support for animation with this would also be cool (and allow for multiple animated sprites in one file). Animated tilesets could also be useful, but slightly less so.

Edit Sprite metadata

Problem
When generating sprites from the importer, I don't see any way to manipulate the pivot of the generated sprites.

Solution
I'd like to be able to edit sprite pivots the same way that unity enables for other image imports. Even if it's not possible to do visually it could at least be exposed as a Vector2 field.

Alternatives
Since the generated sprites and animations are read-only, I'm not sure if any alternative exists. (Maybe I could hack the meta file myself?)

Additional context
This is the sprite editor I'm referring to. It'd also be helpful to expose the other fields here also. I do occasionally use sprite borders or rename sprites, for instance.

Screen Shot 2019-05-08 at 3 05 59 PM

By the way, I love this importer. Thanks for your work on it.

Forked project (Makes it editable)

The 'unity-aseprite-importer' is a good plugin but it only generate not-editable sprites and animations.
So I made a forked project which genetate editable resources.
source code: https://github.com/mjshin82/unity-aseprite-importer

I was thinking 'Pull request' to your project, but it has too many changes and not compatible with the origin.
So I just write this article here. Maybe this plugin could be improved with my approaches someday.

Difference with the origin Aseprite-Importer

  • It makes a sprite sheet file (not dynamic)
  • You can edit the meta like custom physics shapes with the 'Sprite Editor'
  • It generates tilemap with extended-padding, it solves lines tearing issue between tiles.
  • New tilemap name rule support (row-col) which makes you find a certain tile fast.
  • It makes animation files (not dynamic)
  • You can add the custom events to each animation
  • It makes an animation controller
  • Some features are removed (Transparent color, Tilemap empty behavior)

image
image
image

Blend Logic has problem

if calculate blank pixel and opacity pixel( like 1,1,1, 0.5f)

blend more darker than expect cause blank pixel color is (0, 0, 0, 0)

it can be fixed simply, just ignore blank pixel like this

idk about color and blend thats why i fix like that

comment plz if have better way.

image

how to fix these two issues?

After importing Aseprite sprites to Unity, it offsets the whole sprite in Sprite Editor around 4 pixels form edges, and other problem is that after editing the sprite with aseprite example adding more tiles, it offsets the sprite in the editor making a tileset\map change so you have to remake everything, and custom physics shape is messed up as well because of more sprites added, I know I can just add png but I really want to change stuff cause if I have layers.

image
image

Additional atlas creation options

The import inspector should offer options on how the atlas will be created.
Options like how many columns or rows will be created, how much padding should be set between the sprites.

Issue importing layer opacity when using "Normal" blending mode.

Describe the bug
The importer doesn't seem to import any opacity/transparency data when importing an ASE file with semi-transparent layers set to "Normal" blending mode. Is this intended? The result is the sprite not displaying as seen in Aseprite but rather like an alpha-clipped sprite with either full or no transparency.

Expected behavior
I would expect any sprite edited with Aseprite to import with proper transparency values even when using the "Normal" blending mode.

Changing Texture2DBlender.Normal to the following seems to fix the issue, though I'm not sure what other problems this causes:

//c.a = a.a + b.a * (1f - a.a);
c.a = a.a + b.a * opacity;

Screenshots
Image as seen in Aseprite:
Anmerkung 2020-06-22 232256

Imported with the default blending:
Anmerkung 2020-06-22 232320

Imported with the adjusted blending:
Anmerkung 2020-06-22 232351

Desktop (please complete the following information):

  • OS: Windows 10
  • Version: 2020.1

"Secondary Textures" - Normal Map Support

I'm playing with the upcoming unified render pipeline 2D lights and find I'm back to having to export from aseprite manually. I need to add the normal map to the "Secondary Textures" using the sprite editor and I don't see a way to access this while using the importer.

Meta files are not compatible between versions

Describe the bug
Metafiles generated by versions 1.0.0-1.0.1 are not compatible with the newest (1.0.2+) version in any way. Basically adding the newer version will nullify all settings. I think there should be a migration step that will detect the old meta format and will convert it to the new one.

However, during the investigation I figured out that the same behavior is not achievable by the newest versions of the importer, for example:

  • Bundled tile grid doesn't work for me completely and misses the grid size parameter
  • Bundled version of the plain file is not importing multiple sprites and because of that animation is not working.

I guess this issue should be handled when Bundled version of the importer will be stabilized and can be postponed until then.

To Reproduce
Steps to reproduce the behavior:

  1. Create a file & import it using 1.0.1 version of the importer
  2. Bump version of the importer to the newest one

Expected behavior
Metadata files should be migrated and users should be warned about dramatic functionality changes beforehand.

Transparent color option

If someone uses a background-color for transparency it should be possible to replace this color with transparent pixels.

Keyframe recording

Would it be possible (or does it already have) support for keyframe recording? Currently the animations are Read-Only so you can't do any recording, but in scenarios where you might want to change hitbox (collider2ds) with the animation at certain keyframes this would be really useful.

Is it something that can be done? It's such an incredible importer and the ability to add animation events/record keyframe activity would make it perfect.

Renders Incomplete Spritesheet/TileMap (Pink)

Describe the bug
When I try to import an aseprite file the auto-generated tilesheet from the import produces an incomplete output. (See screenshot below)

To Reproduce
Steps to reproduce the behavior:

  1. Import unity-aseprite-importer into my project
  2. Drag and Drop Aseprite into project
  3. Let editor generate

Expected behavior
The spritesheet should have all 7 frames properly rendered; however, only the first frame is showing. The rest shows up as pink.

Screenshots
image

Desktop (please complete the following information):

  • OS: Win10
  • Version: Unity 2018.2.4.f1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.