SpriteMan 3D Tools |
Unity 5.6 added support for layered sprites using Sprite Renderer Sorting Groups. This is very useful for customizing characters by changing things like body parts, clothes and weapons.
Since this usually results in many more sprites and spritesheets needing to be made, SpriteMan comes with a set of special templates and productivity tools for quickly and easily processing hundreds of sprites.
These tools greatly speed up your workflow and simplify swapping the many sprites your games will use for multiple characters. Here's the main workflow these tools simplify.
PREPARE SPRITES - First, prepare the sprite sheets that will be hooked up to your characters' SpriteManager components.
CREATE SPRITEMAN STATES - Second, generate Sprite Manager State templates for customizable characters (body parts, clothing, weapons).
SWAP STATES AT RUNTIME - Third, at runtime, you can now easily swap sets of hundreds of sprites with a few lines of code.
The templates and tools are described in the following sections.
Templates
Contains the names and positions (top-left corner) of frames in a sprite sheet.
The saved state of a SpriteManager you've configured in a scene.
Allows renaming frames in multiple sprite sheets at once.
Allows creating multiple Sprite Manager States using a template SpriteManagerState and multiple sprites.
SpriteMan 3D Tools
Tools > SpriteMan 3D > SpriteMan Tools Window
Saves all the names in a sprite sheet to a reloadable template: Sprite Sheet Map.
Replaces names in a sprite sheet with those from a Sprite Sheet Map - created in the previous tool.
Saves the state of a SpriteManager in your scene to a reloadable template: SpriteMan State.
Convert Sprite Sheet To SpriteMan State
Creates a new SpriteMan State using a SpriteMan State as a template and combining it with a specified sprite sheet.
Loads a SpriteMan State to a SpriteManager in your scene.
Batching Templates (Not Available in Free Version)
Used to replace frame names in multiple sprite sheets, using a source SpriteSheetMap.
Used to generate multiple SpriteMan States, using one source SpriteManState and multiple sprite sheets.
This last section describes some common uses of the SpriteMan tools and templates.
SpriteMan templates are used for saving the states of sprite sheets and SpriteManager components and for batch processing some commonly repetitive tasks. They will make more sense after reading the Tools and Batching sections.
Contains the names and positions (top-left corner) of frames in a sprite sheet.
Created using Save Sprite Sheet Names
Used by Replace Sprite Sheet Names
Contains the states and sprites of SpriteManagers used in your scene. SpriteManager States are ScriptableObjects usable for quickly swapping SpriteManager content of characters in your scene.
Created using Save SpriteMan State and Convert Sprite Sheet to SpriteMan State
Used by Load SpriteMan State
Allows changing the frame names of multiple sprite sheets at once.
Created using the Tools Menu. See Sprite Sheet Batching
Allows converting multiple sprite sheets to SpriteMan States.
Created using the Tools Menu. See SpriteMan State Batching
Open the SpriteMan Tools Window from the Tools menu: Tools > SpriteMan 3D > SpriteMan Tools Window
This tool saves all the names in a sprite sheet to a reloadable template: Sprite Sheet Map.
This tool lets you save all the names of nicely named sprite sheets, so you can easily reload them later with a few clicks. This solves the problem of sprite sheet frame names getting reset when regenerating frames with new settings using Unity's Sprite Editor.
USAGE
Set the Texture to Save with a sprite sheet from the Project view.
Set the Output Folder with a folder from the Project view.
Click Save Map.
Inspect the newly created Sprite Sheet Map.
This tool replaces names in a sprite sheet with those from a Sprite Sheet Map - created in the previous tool.
USAGE
Set the Source Sprite Sheet Map from the Project view.
Set the Target Sprite Sheet texture from the Project view.
Click Replace Names.
Inspect your target sprite sheet texture names.
See the tool's generated output. Source frames that didn't have matching target frames will be listed. This happens when positions of frames don't match exactly. The output lets you easily see which frames have problems.
Having mismatched frames isn't always bad. In some cases, it's expected that certain frames of things like clothes, weapons or accessories will not have an existing frame. Those frames can safely be ignored.
This tool saves the state of a SpriteManager in your scene to a reloadable template: SpriteMan State.
USAGE
Set the Sprite Manager with a Sprite Manager from your Scene hierarchy.
Set the Output Folder with a folder from the Project view.
Click Save State.
Inspect the newly created Sprite Manager State.
This tool creates a new SpriteMan State using a SpriteMan State as a template and combining it with a specified sprite sheet.
USAGE
Set the Source SpriteMan State with a SpriteManager State from the Project view.
Set the Sprite Sheet To Use with a sprite sheet from the Project view.
Set the Output Folder with a folder from the Project view.
Click Generate SpriteMan State.
Inspect the newly created SpriteMan State.
This tool loads a SpriteMan State to a SpriteManager in your scene.
USAGE
Set the Source SpriteMan State with a SpriteMan Staet from the Project view.
Set the Target Sprite Manager with a Sprite Manager from your Scene hierarchy.
Click Save Map.
Inspect the newly created Sprite Sheet Map.
Using a Sprite Sheet Batch, you can rename multiple sprite sheets at once.
USAGE
Create a new Sprite Sheet Batch from the Tools menu. (Tools > SpriteMan 3D > Create > Sprite Sheet Batch)
Set the Source Sprite Sheet Map with a Sprite Sheet Map from your Project view.
Set multiple Targets with sprite sheets from your Project view.
Click Process Batch any time you wish to rename all the sprite sheets.
Inspect the renamed sprite sheets.
Using a SpriteMan State Batch, you can generate multiple SpriteMan states at once.
USAGE
Create a new SpriteMan State Batch from the Tools menu. (Tools > SpriteMan 3D > Create > SpriteMan State Batch)
Set the Source State with a SpriteMan State from your Project view.
Set multiple Targets with a sprite sheets from your Project view.
Set the Output Folder with a folder from the Project view.
Click Process Batch whenever you wish to regenerate your states.
Inspect the newly created SpriteMan States.
This section contains the following subsections:
Imagine you generate frames for a sprite sheet using Unity's Sprite Editor.
You slice the sprite sheet using the following settings.
The frame names generated are in the form sheetName_0, sheetName_1.
So, you rename your frames individually to be more readable (ex: idle-e, walk-e.1, walk-e.2).
Now use the Save Sprite Sheet Names tool to save all your sprite sheet names.
After using this sprite sheet a bit, you decide you'd like to change the frame pivot positions (say from Bottom to Center).
You use Unity's Sprite Editor to make the change by regenerating the frames with new settings.
This has reset all the frame names to defaults (sheetName_0, sheetName_1).
Use the Replace Sprite Sheet Names tool to reload your saved names.
(Without these tools, you have to manually rename your frames to their readable forms again - all 150 of them.)
Imagine you slice a sprite sheet using the following settings.
The frame names generated are in the form sheetName_0, sheetName_1.
So, you rename your frames individually to be more readable (ex: idle-e, walk-e.1, walk-e.2).
Now use the Save Sprite Sheet Names tool to save all your sprite sheet names.
Say you have multiple sprite sheets containing various sets of clothing that will overlay the main body sprite.
Use the Replace Sprite Sheet Names tool to quickly replace the names of the additional sprite sheets.
Alternatively, use a Sprite Sheet Batch to replace the names of multiple sprite sheets with one click.
There's a sample scene for this in the asset's Demo Scenes folder: Clothing Demo.
This example has a rigged SpriteManager character with a base body.
On top of that are displayed multiple layers with swappable clothes and weapons.
To reproduce this with your own sprites, first, slice your sprite sheets.
Then rename the frames of a main body sprite sheet and use the Save Sprite Sheet Names tool to save your names.
Next, use a Sprite Sheet Batch to rename your sprite sheet frames for all the other sprite sheets.
Use a SpriteMan State Batch to generate all the swappable sets of clothes.
Overlay the new clothes using child SpriteManagers that render on top of the body SpriteManager.
Important |
---|
Make sure to use a SortingGroup for the layers to work correctly. |
In the editor, use the Load SpriteMan State tool to test the new clothes on your character.
At runtime, you can load SpriteMan States from a Resources folder and swap them using the SpriteManager.LoadSpriteManState() method.
(There's also a different working example in the demo scene.)
/// <summary> /// This behaviour allows changing a character's clothes. /// </summary> public class StateSwap : MonoBehaviour { private SpriteManagerState[] clothes; public SpriteManager clothingSpriteManager; void Start() { // load SpriteManagerStates at runtime from a Resources folder. clothes = new[] { Resources.Load<SpriteManagerState>("clothes/leather"), Resources.Load<SpriteManagerState>("clothes/mail"), Resources.Load<SpriteManagerState>("clothes/armor") }; } /// <summary> /// This method can be called from a UI button. /// </summary> /// <param name="index"></param> public void ChangeClothes(int index) { if (clothingSpriteManager != null && index < clothes.Length) { // swap a SpriteManager's state using SpriteManager.LoadSpriteManState(). clothingSpriteManager.CopyFrom(clothes[index]); } } }