Chapter 39: Export Harmony Animations to Unity
At this point, if you have a custom game engine, you can take the exported data and proceed with your usual process. Or you can modify the export script to fit your convention.
If you’re going into Unity, here are some things you need to do:
• | Exporting the Animation |
• | Opening the Sample Unity Project |
• | Working in Unity |
Exporting the Animation
First, you must put the script in your Scripting toolbar (TB_ExportToSpriteSheets). This script is included in the latest build of Harmony. Make sure to verify that you have the latest version of Harmony.
If you were already using a previous build of the Gaming Pipeline, you will need to remove the old scripts from your preferences, so you can use the new scripts.
- Close Harmony if it is open.
- Browse to the script folder location:
• Windows:
• Toon Boom Harmony Advanced: C:\Users\[user_name]\AppData\Roaming\Toon Boom Animation\Toon Boom StageAdvanced\1200-scripts
• Mac OS X: On Mac OS X, the Library folder is a hidden folder. To display the display the folder, told down the Alt key.
• Toon Boom Harmony Advanced: /Users/[user_name]/Library/Preferences/Toon Boom Animation/Toon Boom Stage Advanced/1200-scripts
- Delete the 1200-scripts folder.
- Restart Harmony and test the export.
- From the top menu, select Windows > Toolbars > Scripting.
- In the Scripting toolbar, click the Manage Scripts button to display the Scripts Manager.
- In the Scripts Manager, select TB_ExportToSpriteSheets from the Files column.
- In the Functions column, select TB_ExportToSpriteSheets and then click the right arrow button to add it to the toolbar.
- Click OK.
- Run the script by clicking the New icon on the right side of the Scripting toolbar.
The Export to Sprite Sheets dialog box opens.
- Set the Save Path to the correct folder in your Unity project if you want it to update automatically. If not, you can save anywhere, then transfer the animation into your Unity project, or any other game engine you want to use.
- Set your sprite sheet preferences:
Parameter | Description |
Max Width, Max Height | This is a value, in pixels, fpr the maximum width and height the exported sprite sheet should be. By default, both values are set to 2048 pixels. |
Expand Sprite Sheet |
Uses the minimum size necessary up until it reaches the maximum resolution. |
Fixed Resolution | Creates a texture of the specified size (Max Width and Max Height) even if it does not fill it up completely. |
Resolution Type |
POT: Exports to sprite sheets with sizes that are a power of 2. For example: 1024 x 1024. This is optimized for many graphics cards, but consumes more memory. NPOT: Some game engines are optimized specifically to render to non powers of two, so that it will avoid those numbers. Example: 1000 x 1000. |
Reuse Frames | |
Threshold | |
Sprite Resolutions | Size of the render of the individual sprite, when it exports each drawing out. |
The exporter will export to multiple resolutions based on the settings. Saves different animations of the same character into the same Save Name. For example, if there's an idle, run, and jump animation, these should all share the same Save Name. You can think of it as the overall collection of animations. Inside are the different saved scene versions whose drawings you can reuse for all the animations in that character set. Each scene version will be displayed as an item in the list. When you export an animation, only the drawings used in that scene are exported. All the drawings are exported individually first and then atlased together into a sprite sheet. If you save multiple animations to the same Save Name (i.e. SpaceDuck: run, idle), then it will re-atlas the sprite sheet to include all the drawings from all the animations in that folder, creating a new animation file, but reusing the same skeleton. |
|
Precalculate Curves | Makes linear values for interpolation. This increases the amount of memory used but frees up the calculation so it is not done on the fly. |
Programmers may be interested to note that the XML data exported by Harmony can be converted afterwards to a more optimized binary data structure. The binary converter is not yet available for Harmony, but it can be compiled manually in the game engine package. The C++ code that handles the data structure can be reused and parsed in your own code if you want to integrate with other game engines.
Additional Note
• | The Transparency parameter attached to the element node is exported along with the animation. You can set the transparency through the Layer Properties window (Advanced tab). |