This tutorial will guide you how to import After Effect animation to your project from scratch after you got the plugin.
Animation export script
You can skip this step. But in this case you will have to specify export script location every time when you want to run it.
When After Effects starts, it loads scripts from the Scripts folder. By default, the Scripts folder is in the following location:
(Windows) Program Files\Adobe\Adobe After Effects CS4\Support Files
(Mac OS) Applications/Adobe After Effects CS4
Put script from Assets/Extensions/AfterEffect/External/Unity3D Export.jsx to the your After Effect Script folder.
To run the script go to File → Scripts → Unity3D Export.jsx. Or if you skipped the last step, you can run this from any location. To do this, go to the File → Scripts → Run Script File → and choose Unity3D Export.jsx from your hard drive.
Note: Before you can execute export scripts in the After Effect editor you need to allow scripts to write files, as showed on the screenshot bellow:
Make sure that your current composition is selected. You will get an error if you do not select composition for export. If you have big animation with a lot of frames and layers, it can take a while to export animation data. After exporter script finishes running you will get *.xml file on your desktop with the composition data.
Put Animation data file to the Unity project.
Running animation inside Unity
Next we create and init After Effect animation game object.
- Put your animation source images inside the Resource folder of your project. Doesn't matter where exactly you put your source images, just make sure they inside resource folder. Let's put them in the Root of Resource folder for this tutorial.
- Modify images import settings:
Texture Type: Sprite:
Pivot: Top Left
Other texture import settings are up to you.
- Go to the: Game Object → Create Other → After Effect → Animation
- Select created Gameobject. Drag your animation data file to the Animation Data field of After Effect Animation component
If you did everything right you should see animation preview in your editor now.
After Effect Animation options
- Data File. Animation data file. Drag animation data file to this field to apply.
- Images Folder. Source Images of animation should be in one folder inside Resource folder of your project. Images Folder should contain the path to that folder relative to Resource folder. If your images in the root location Resource of folder, just leave it empty.
- Gizmos Color. Color of Animation Gizmo.
- Material Color. Sprites material color. If used shader support color property. While color by default.
- Current Frame. Current frame of animation. Drag this slider to get animation preview.
- Time Scale. Timescale of animation.
- Opacity. Animation opacity.
- Play On Start. Animation will start playing when game object will receive Start event if active.
- Play Backward. Use this option to invert play direction.
- Loop. Enable / Disable animation loop.
- CPU Optimization. Extension will skip transformations if the transformation not changed compare to the previous frame. This may cause problems it you will manually set the frames.
- Pivot Center X. X pivot center of animation. Valuer from 0 to 1.
- Pivot Center Y . Y pivot center of animation. Valuer from 0 to 1.