Licensing

A Spine license is required to integrate the Spine Runtimes into your applications.

spine-unity Runtime Documentation

Example Scenes

The spine-unity runtime includes example scenes to demonstrate the most important components and usage of the C# API for common use cases. You can find them in the Spine Examples top level directory. Each scene includes a description text that will help you to quickly discover and understand the relevant parts. This video provides an overview of the example scenes included in the spine-unity runtime.

If you are using the spine-unity runtime for the first time, it is highly recommended to check out at least the example scenes in the Spine Examples/Getting Started.

Spine Examples / Getting Started

The example scenes in the Spine Examples/Getting Started demonstrate the fundamental components and basic use cases.

1 The Spine GameObject

This scene demonstrates the SkeletonAnimation component and the referenced SkeletonDataAsset which provides the necessary data.

2 Controlling Animation

This scene demonstrates basic animation code using the C# API - starting animations and reacting to animation events.

When pressing play, Spineboy will sequentially play animations walk, run, idle, and turn. Footstep events will trigger a sound accordingly.

You can inspect the example script SpineBeginnerTwo component which is attached at the spineboy GameObject. It demonstrates usage of SkeletonAnimation.AnimationState.SetAnimation() and SkeletonAnimation.AnimationState.AddAnimation(). The script HandleEventWithAudioExample attached at the sound GameObject shows how you can hook up your own event method callback by registering it at SkeletonAnimation.AnimationState.Event.

3 Controlling Animation Continued

This scene demonstrates how you can play animations simultaneously by using multiple animation tracks. It also shows how to use AnimationReferenceAssets as an alternative to using animation name strings.

When pressing play, the walk animation will start to play in a loop. At the same time, and in its own timeframe, the gungrab and gunkeep animations are playing as a secondary animation.

You can inspect the example script Raptor attached at the raptor Skeleton GameObject. It shows how to expose AnimationReferenceAsset properties at a component and assign it as animation by calling the SkeletonAnimation.AnimationState.SetAnimation() method, on tracks 0 and 1.

4 Object Oriented Sample

This scene demonstrates how you can setup a platformer character following the Model-View-Controller object oriented software design pattern. Please note that while this setup might not be the most suitable for your projects, it shall serve as inspiration on how input, game logic and visualization may be separated into components.

When pressing play, you can control the Spineboy character with WASD (move), Spacebar (jump) and mouse input (aim and fire). Alternatively you can control it via an XBOX Controller.

You can inspect the example script SpineboyBeginnerInput attached at the PLAYER INPUT GameObject, acting as controller. It modifies the state of the model represented by the SpineboyBeginnerModel component attached at the PLAYER Spineboy GameObject. Visualization of this state is performed by the SpineboyBeginnerView component, attached at the VIEW Spineboy GameObject, acting as view. It starts the respective animations at the SkeletonAnimation component which is attached at the same GameObject.

5 Basic Platformer

This scene demonstrates the use case of a platformer with typical animations such as jump, run, fall, land, complete with particles and sound effects. It also shows how Spine meshes can be used to cast shadows in Unity.

Note: If you do not see any cast shadows, please enable shadows via Edit - Preferences - Quality - Shadows (Unity - Preferences on Mac).

When pressing play, you can control the Hero character with WASD (move) and Spacebar (jump). Alternatively you can control it via an XBOX Controller.

You can inspect the example script BasicPlatformerController attached at the Player GameObject. It shows how you can use Unity input to change between a character's states which are tracked in a newly created CharacterState attribute. When states change, the SkeletonAnimationHandleExample example script is used to transition to the new animation, while the HeroEffectsHandlerExample example script is used to play a sound and spawn particle systems.

6 SkeletonGraphic

This scene demonstrates the SkeletonGraphic component and how it can be integrated into an existing Unity UI. It also shows how BoneFollowerGraphic components can be used to attach text labels to follow bone positions. They can be found at the Detached BoneFollowerGraphic and Child BoneFollowerGraphic GameObjects.

When pressing play, you will see a Canvas-based user interface where Doi and Spineboy are integrated into a scrollable panel. Both play looping animations just as a SkeletonAnimation component while being part of the UI.

Next: Assets Previous: Installation