DragonBones skeletal animation runtime for Unity, supporting playback and management of DragonBones skeletal animations.
- ✅ Full skeletal animation playback support
- ✅ Animation blending and layer playback
- ✅ Mesh Deformation
- ✅ Inverse Kinematics (IK)
- ✅ Bounding box collision detection
- ✅ UGUI support
- ✅ Event system
- ✅ Skin and slot replacement support
- ✅ Custom shader support
- Download the latest
DragonBonesUnity.unitypackagefrom the Releases page - Double-click the
.unitypackagefile in Unity Editor to import - Done!
- Copy the
Assets/DragonBonesfolder into your Unity project's Assets directory - Wait for Unity to finish compiling
From Unity menu:
GameObject → DragonBones → Armature Object
Or select an imported DragonBones data file (*_ske.json), right-click and select:
Create → DragonBones → Armature Object
using DragonBones;
using UnityEngine;
public class DragonBonesDemo : MonoBehaviour
{
private UnityArmatureComponent armature;
void Start()
{
armature = GetComponent<UnityArmatureComponent>();
// Play animation
armature.animation.Play("walk");
// Loop infinitely
armature.animation.Play("walk", 0);
}
void Update()
{
// Switch animation on click
if (Input.GetMouseButtonDown(0))
{
armature.animation.FadeIn("jump", 0.2f);
}
}
}| Property/Method | Description |
|---|---|
animation |
Animation controller |
armature |
Armature object |
armatureName |
Armature name |
unityData |
DragonBones data asset |
sortingLayerName |
Sorting layer name |
sortingOrder |
Sorting order |
flipX / flipY |
X/Y axis flip |
timeScale |
Animation playback speed |
// Play animation
armature.animation.Play("animationName");
// Cross-fade to animation
armature.animation.FadeIn("animationName", 0.3f);
// Pause
armature.animation.Stop();
// Play count (0 for infinite loop)
armature.animation.Play("animationName", 0);
// Get current animation state
var state = armature.animation.GetState("animationName");
state.timeScale = 0.5f; // Slow down this animationvoid Start()
{
armature = GetComponent<UnityArmatureComponent>();
armature.AddDBEventListener(EventObject.COMPLETE, OnAnimationComplete);
armature.AddDBEventListener(EventObject.FRAME_EVENT, OnFrameEvent);
}
void OnAnimationComplete(string type, EventObject eventObject)
{
Debug.Log("Animation complete: " + eventObject.animationState.name);
}
void OnFrameEvent(string type, EventObject eventObject)
{
Debug.Log("Frame event triggered: " + eventObject.name);
}// Replace slot display
var slot = armature.armature.GetSlot("weapon_slot");
slot.displayIndex = 1; // Switch to 2nd display object
// Change skin
var skinData = armature.armature.armatureData.GetSkin("hero_blue");
armature.armature.SwapSkin(skinData);Plugin includes the following demo scenes (located in Assets/DragonBones/Demos/Scenes/):
| Scene | Description |
|---|---|
1.HellowDragonBones.unity |
Basic animation playback |
2.AnimationBase.unity |
Animation basic operations |
3.DragonBonesEvent.unity |
Event system usage |
4.AnimationLayer.unity |
Animation layer blending |
5.BoneOffset.unity |
Bone offset control |
6.InverseKinematics.unity |
IK Inverse Kinematics |
7.BoundingBox.unity |
Bounding box collision |
8.ReplaceSlotDisplay.unity |
Slot display replacement |
9.ReplaceSkin.unity |
Complete skin replacement |
10.ReplaceAnimation.unity |
Animation data replacement |
11.CoreElement.unity |
Core elements demo |
UGUIDisplay.unity |
Usage in UGUI |
Performance.unity |
Performance test |
LightShader.unity |
Custom shader demo |
- Export data from DragonBones Pro editor
- Copy exported files (
*_ske.json,*_tex.json,*_tex.png) into Unity project - Select the
*_ske.jsonfile, right-click menu select:Create → DragonBones → Create Unity Data - A
*_Data.assetfile will be generated - this is the Unity-compatible data resource
- Ensure DragonBones Pro exported data version is compatible with the plugin
- Currently supports DragonBones 5.x format data
- Version incompatibility will automatically show an error dialog
Create UGUI mode Armature:
GameObject → DragonBones → Armature Object(UGUI)
Or set in code:
armature.isUGUI = true;- Reduce draw calls: Enable
closeCombineMeshesto merge meshes - Control on-screen count: Consider object pooling for many characters
- Adjust frame rate: Use
timeScaleto adjust animation speed - Unload unused data: Use
UnityFactory.factory.Clear()to clean cache
A: Ensure *_Data.asset file was generated correctly and material paths are correct. Re-run "Create Unity Data".
A: Material shader missing. Check if the shader used by the material exists, or reassign the correct shader.
A: Plugin will automatically show version incompatibility dialog. Convert the data to a supported version using DragonBones Pro.
A:
armature.timeScale = 0.5f; // Slow down globally
// Or adjust single animation
var state = armature.animation.Play("walk");
state.timeScale = 0.8f;MIT License - See LICENSE file for details