2D Toolkit Forum

2D Toolkit => Support => Topic started by: MindsEye on April 09, 2017, 09:55:03 pm

Title: REQUEST: Easy cloning/reskinning of sprite collections and animations
Post by: MindsEye on April 09, 2017, 09:55:03 pm
Hi! I've been using 2D toolkit for quite a while with my game Blast Brawl 2 (Steam link:http://store.steampowered.com/app/447980 (http://store.steampowered.com/app/447980)). 2D Toolkit is GREAT, much better than current standard 2D support in unity, but I have a few requests for tweaks/additions that would be extremely useful in certain situations.

A very common use case I have run into is wanting to leverage already created 2D toolkit data (sprite collections, animation libraries) to make it faster to create similar data. A perfect example would be player "skins," where you can create another version of the player sprites and have all of the animations, attach points, collision, dicing, etc be the same but with different actual image data. Ideally the process to create this similar sprite should be easy, since I've already done all the work of setting up the base sprite.

Several generic options make this surprisingly easy, I'd like to request they - or something equivalent - be added to the plugin.

NOTE: I have actually implemented this (though in an older version of tk2d than is currently live) and can provide code if it would help make this a reality in the actual plugin!

1: DUPLICATING/IMPORTING SPRITE COLLECTION DATA
First off, it seems very difficult in general to safely duplicate sprite collections - I don't think this is currently supported? Duplicating a collection via Unity seems to require a rebuild (which makes sense) and unless things have changed in a more recent version I don't think there's an option in the tk2d editors.

Regardless, it would be quite helpful if you could make total copies of sprite collections, with the intent of tweaking the cloned data. The solution I implemented added an "Import" button into the menu bar of the sprite collection editor. Clicking it detects the active selected object, and if it is a sprite collection it will create sprites with identical names/images/data/etc to the ones in the selected collection (obviously IDs are not guaranteed to be the same, and my implementation didn't create copied sprites if something with the same name existed in the collection already).



2: "REBASING" SPRITES IN A COLLECTION TO POINT TO DIFFERENT SOURCE IMAGES
Likewise, it's nice to be able to do a large-scale edit of what sprites in a collection look like, without needing to update textures by hand per-sprite, and while leaving the original image files intact.

Sprite sheets seem like the obvious place to implement this, as there's a logical flow of:


but it should not be the only way to rebase images.

In my case, I stored all images for a sprite collection in a specific folder close by, so I implemented this the following way: I added another button on the menu bar of the sprite collection editor, called "Rebase Images." Clicking it detected the selected image or all images below a selected folder in the unity editor. For every selected image, it tried to find all matching sprites in the collection that were based on an image with the same name, updating their referenced image when it did.

It's possible there's a more generic solution that allows for more arbitrary file system setups, such as possibly requiring the user to specifically select the images to choose from. Idk! It's very useful though.



3: DUPLICATING/IMPORTING ANIMATION LIBRARY DATA
Similarly, it's nice to duplicate animations! I added a similar button in the animation editor that detected a selected animation library and copied all the animations in it into the currently edited animation library.



4: "REBASING" ANIMATION LIBRARY DATA TO DIFFERENT SPRITE COLLECTIONS
ALSO similarly, it's extremely useful to rebase copied animation data onto a new sprite collection(s). My implementation was pretty similar to the stuff above, and just changed referenced sprites based on matching sprite names.



That's pretty much it! Does this sound like something that might be added to base 2d toolkit? It's a bit more technical but very useful for large-scale projects!