Getting Started
Adding Rive to your Unity game
Last updated
Adding Rive to your Unity game
Last updated
This article is out of date! Find the new version here.
The rive-unity package is currently in Technical Preview for macOS and Windows. We're hoping to gather feedback about the API and feature-set as we expand platform support. There may be sudden breaking changes between versions and not all Rive runtime features are supported yet - see Feature Support
To quickly experiment with rive-unity, run one of our example projects: https://github.com/rive-app/rive-unity-examples
The rive-unity package is available to install from GitHub.
You will need a Unity editor that supports OpenGL or D3D11 for Windows, or a Mac with ARM64 (M1, M2, etc) architecture.
On Mac with ARM64 you do not need to configure anything. To manually update select either D3D11/OpenGL for Windows, or Metal for Mac/iOS as the Graphics API under Edit -> Project Settings -> Player in Unity.
You can install the Rive package for Unity by opening the Package Manager and adding the latest tag as a git dependency:
Or through HTTP:
Open Window -> Package Manager
Choose Add package from git URL...
Add the URL with version tag
You can also add and update it manually to your projects Packages/manifest.json
file:
A .riv
file can be added like any other Unity asset, by dragging it into the Assets
folder. You can preview the animation in the inspector by selecting it.
A Rive.File
contains Artboards, StateMachines, and Animations. There are higher-level behaviors that you can use directly in the Unity editor. Use this class if you need direct control of the lifecycle of the Rive File.
A Rive File can be created from a Rive Asset (.riv):
An Artboard contains StateMachines and Animations. Artboards are instantiated from a Rive.File
instance:
A StateMachine contains Inputs and Events. For more information see Unity State Machines and Events.
State Machines are instantiated from an Arboard instance:
They also control advancing (playing) an animation:
Rive Unity renders to a RenderTexture that you can display in your Scene by attaching to a Material or drawing to the camera. Layout and draw commands are managed through the Rive.Renderer
.
For a more complex example of drawing a texture directly to a camera, see the getting-started project in the examples repository.
The following is a basic example script behaviour to render a given Rive asset to the provided renderTexture
. The animation is played by calling .Advance()
on the State Machine.
See Animation Playback for more general information on playing animations and state machines at runtime.
Create a Unity RenderTexture and Material in Assets
Assign the RenderTexture to the Material
Drag this behaviour to a GameObject and attach the material
Link the .riv
asset and RenderTexture on the RiveTexture (custom script) behaviour