Share
Cutscenes in Unity
For Unity, Export Cutscene writes a small editor script, Editor/CiwbCutsceneBuilder.cs, that turns the export into a Timeline in your open scene: motion, camera cuts, zooms and sound.
What you need
- glTFast (
com.unity.cloud.gltfast) to import the.glb. Add it in Window > Package Manager > + > Add package by name. - Timeline (
com.unity.timeline). Most projects have it already.
Set it up
- In Ciwb, choose File > Export > Export Cutscene…, pick Unity and export into a folder.
- Copy the whole folder into your project's
Assets, for exampleAssets/Cutscenes/Gold/. The script must stay in the folder calledEditor, which Unity runs only in the editor. - When Unity has imported everything, select
Name.cutscene.jsonin the Project window. - Choose Tools > Ciwb > Build Cutscene Timeline. It is also on the right-click menu, under Ciwb.
The script switches the .glb's animation import to Mecanim if it was set to Legacy (Timeline only plays Mecanim clips), puts the scene in your open scene and builds the Timeline. Press Play and the cutscene runs.
What it builds
| Thing | What it does |
|---|---|
Name | The .glb scene as a prefab instance, with an Animator |
Name Director | A PlayableDirector that plays on awake, with an AudioSource for the sound |
Name.playable | The Timeline asset, saved next to the JSON |
The Timeline has:
- Motion: an Animation track playing the baked animation on the scene's Animator,
- Cut tracks: an Activation track per camera, active during each of its shots. Only one camera is active at a time, so Unity renders through it,
- Lens tracks: for cameras whose zoom changes, an Animation track keying the camera's field of view on every frame,
- Sound: an Audio track with the WAV.
Running the command again replaces the Timeline and the objects it made before, so re-export and rebuild whenever the film changes.
Good to know
- Unity's camera field of view is vertical, as in Ciwb, so the framing matches.
- Shots appear as named clips on the Cut tracks, so you can see the edit at a glance and adjust it in Unity.
- To hand control back to your game camera at the end, enable it from a Signal on the Timeline or when the PlayableDirector's
stoppedevent fires. - If the Motion track is missing, the
.glbhad no Mecanim clip. Check that its import settings show Animation: Mecanim, then build again.