gindemit/unity-rlottie
حول
Unity library that plays Lottie Animation to Texture2D
التصميم والوسائطما يمكنك فعله
- Play Lottie animations as Texture2D in Unity
- Easy integration and usage
- High performance and low memory footprint
- Uses Samsung's rlottie library internally
النمو المقاس للنجوم
- خلال 24 ساعة
- ٠
- خلال 7 أيام
- ٠
- خلال 15 يومًا
- ٠
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصلUnity Lottie Animation Plugin
🧪 EXPERIMENTAL RELEASE AVAILABLE!
We need your help testing v0.5.0-experimental.1 which introduces native rendering features and WebGL support!
This release moves texture updates to the native plugin layer for better performance. Please test and report any issues you encounter.
Welcome to the Unity Lottie Animation plugin! This Unity library enables you to play Lottie animations as Texture2D in your Unity projects. It's a powerful and easy-to-use solution that leverages Samsung's rlottie library to bring smooth Lottie animations to your games and applications.
Lottie loads and renders animations and vectors exported in the bodymovin JSON format. Bodymovin JSON can be created and exported from After Effects with bodymovin, Sketch with Lottie Sketch Export, and from Haiku.
For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand. Since the animation is backed by JSON they are extremely small in size but can be large in complexity!
Features
- Play Lottie animations as Texture2D in Unity
- Easy integration and usage
- High performance and low memory footprint
- Uses Samsung's rlottie library internally
- Compatible with Unity 2019.4 and later
Supported Platforms
- Android
- iOS
- Windows
- OSX
- Linux
Installation
To install the Unity Lottie Animation to Texture2D plugin using the Unity Package Manager, follow these steps:
- Open your Unity project and navigate to
Window>Package Manager. - Click the
+button in the top-left corner and selectAdd package from git URL.... - Enter the following URL and click
Add:https://github.com/gindemit/unity-rlottie.git?path=/unity/RLottieUnity/Assets/LottiePlugin/#0.4.5
Quick Start
Native library contract
Update the managed scripts and platform native libraries together. The managed code requires the current native API; missing libraries or exported functions are integration errors and must not be hidden with compatibility fallbacks. Contributors and subagents must follow this rule when changing native calls. Device/backend capability checks and recovery from reported upload failures remain part of normal rendering behavior.
iOS uses native Metal rendering and polls the pending-upload count through
__Internal, just like other native platforms. WebGL has a separate upload path
and does not call that queue query.
The LottiePlugin.UI namespace includes a AnimatedImage class which allows you to use Lottie animations as RawImage in your Unity game.
Here are the steps to use the AnimatedImage class in your Unity project:
Import the Class: First, make sure the
AnimatedImageclass is included in your Unity project.Create an RawImage: In your Unity scene, create a new RawImage UGUI game object and attach the
AnimatedImagescript to it.Assign Parameters: In the
AnimatedImagecomponent, you will see several parameters:- Animation Json: A
TextAssetrepresenting the JSON data for your Lottie animation. You can drag and drop it from your Assets folder. - Texture Width: Defines the width of the texture for the animation. Increasing this value will improve the quality of the animation by increasing the number of pixels, but it may also impact performance, especially on lower-end hardware.
- Texture Height: Defines the height of the texture for the animation. Similar to Texture Width, increasing this value enhances the quality of the animation by adding more pixels, but it could potentially degrade performance on less powerful devices.
- Animation Speed: Speed at which animation plays. 1 is normal speed.
- Play On Awake: If checked, the animation will start playing as soon as the scene starts.
- Loop: If checked, the animation will keep playing in a loop.
Fill these in according to your needs.
- Animation Json: A
Play/Stop the Animation: You can use the
Play()andStop()methods to control the animation at runtime. You can call these from any other script.// Get a reference to the AnimatedImage AnimatedImage animatedImage = gameObject.GetComponent<AnimatedImage>(); // Play the animation animatedImage.Play(); // Stop the animation animatedImage.Stop();
And that's it! You are now able to use Lottie animations in your Unity projects using the AnimatedImage class.
Review a Lottie export
Use the local export review command to find compatibility issues in self-contained vector JSON and render a transparent filmstrip with the Windows plugin. The command can also write a separate copy that corrects misplaced shape type keys for the pinned rlottie parser.
Logging
The plugin logs warnings and errors by default. To change the global native log level at runtime, call:
LottiePlugin.LottieAnimation.SetGlobalLogLevel(LottiePlugin.LottieLogLevel.Info);
Choose Info for diagnostic messages, Error for errors only, or None to
silence native logging. This works with the native libraries supplied by the
plugin; no native rebuild is needed. The global setting controls messages
without a specific animation instance, including texture upload messages.
For an individual animation, set LottieAnimationOptions.LogLevel when loading
it or change its LottieAnimation.LogLevel property later. The AnimatedImage
and AnimatedButton components also expose an individual Log Level setting in
the Inspector.
Example
Here's an example of how to use the AnimatedImage class:
// Attach this script to a GameObject with AnimatedImage component
using UnityEngine;
using LottiePlugin.UI;
public class AnimationController : MonoBehaviour
{
private AnimatedImage animatedImage;
private void Awake()
{
animatedImage = GetComponent<AnimatedImage>();
}
private void Start()
{
animatedImage.Play(); // Start the animation
}
private void OnDisable()
{
animatedImage.Stop(); // Stop the animation
}
}
This script, when attached to the same GameObject as the AnimatedImage component, will start the animation when the game starts and stop it when the GameObject is disabled.
Other Examples
Check out the 'Scene UI' Sample in Unity Package manager.
- Open your Unity project and navigate to
Window>Package Manager. - Select the installed Lottie Animation package on the left
- Fold out the Samples section
- Click 'Import' button on the Scene UI sample
- After importing it will ask you to copy the sample animations to the Assets/StreaminAssets folder
- Click 'Copy' button in the 'Missing lottie animations' dialog
- Open the 'SampleScene' from the sample in 'Assets/Samples/Lottie Animation/[version]/Scene UI/Scenes/' folder
- Hit play in Unity editor
https://github.com/gindemit/unity-rlottie/assets/5675979/3301d00e-fc9e-49c0-bc7f-7408f1f72ce4
Android device tests
From the repository root, use one USB-connected Android device with debugging enabled and the project's Unity editor with Android Build Support installed.
$editor = "$env:ProgramFiles\Unity\Hub\Editor\2022.3.62f3\Editor\Unity.exe"
.\scripts\ci\run-android-qualification.ps1 -Unity $editor -ProjectPath .\unity\RLottieUnity `
-OutputDirectory "$env:TEMP\rlottie-qualification" -LifecycleCycles 120
The runner builds and launches Vulkan and OpenGL ES 3 players, checks rendered pixels and texture disposal, and runs the plugin's Android runtime assembly. Read qualification.json for pass counts, backend names, failures and evidence paths. Each backend also produces a screenshot, full player log and detailed JSON. The runtime suite writes NUnit XML that the runner can recover over USB after an editor heartbeat timeout.
Core performance regression checks
Core performance runs after core changes on main and on same-repository pull requests targeting main. It builds the Release native plugin and a Unity player for each revision. A single Linux runner alternates five baseline/candidate launch pairs with the same animation and measures repeated file loads, loads from JSON data, CPU frame rasterization and parallel frame preparation. The baseline is the previous tip for pushes and the base commit for pull requests. Use workflow dispatch to compare explicit SHAs, including trusted revisions from external pull requests that need repository Unity credentials to run.
Each launch uses the median of nine measured rounds after a warmup round. The job fails when at least three pairs exceed both the 12% CPU slowdown limit and that metric's absolute millisecond floor. The step summary shows the paired changes. The core-performance-results artifact contains the thresholds, per-pair results, raw timings and player logs.
For CPU and native D3D12 measurements on a Windows GPU, run the following from the repository root with Unity 2022.3.62f3 and Python 3 installed. It stages both Git revisions outside the checkout and uses their packaged Windows DLLs. The D3D12 pass measures draw time, player frame time and p95 disposal latency after an upload, with a 15% relative limit and per-metric absolute floors. The hosted check uses Unity's headless graphics device. Android device qualification remains a separate check.
./scripts/benchmarks/run-windows-core-performance.ps1 -Baseline 7f56e754 -Candidate 1246a098 `
-Unity 'C:/Program Files/Unity/Hub/Editor/2022.3.62f3/Editor/Unity.exe' `
-ResultsRoot 'C:/benchmarks/rlottie-core-comparison'
Documentation
- Texture upload paths and Vulkan native-upload analysis
- Markers, CPU rasterization, and shared frame caches
- Runtime fill/stroke color overrides and semantic palette slots
- Marker/cache implementation validation (2026-09-11)
Support
If you encounter any issues or have questions, please create an issue on GitHub.
Credits
This plugin is built on top of Samsung's rlottie library, which is used internally for Lottie animation rendering.
License
This project is licensed under the MIT License. See the LICENSE file for details.
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…