龙骨官网
http://dragonbones.com/cn/index.html
unity 龙骨插件
https://github.com/DragonBones/DragonBoneToUnity
龙骨封装
private readonly string logoPath = "DB_Anim/";
public GameObject Play( string bonesData, string atlasData, string animation, int times = 1 ) {
TextAsset dragonText = Resources.Load(( this.logoPath + bonesData ),typeof(TextAsset)) as TextAsset;
TextAsset atlasText = Resources.Load(( this.logoPath + atlasData ), typeof(TextAsset) ) as TextAsset;
Texture2D texture = Resources.Load(( this.logoPath + atlasData ), typeof(Texture2D)) as Texture2D;
UnityFactory.factory.LoadDragonBonesData(dragonText);
UnityFactory.factory.LoadTextureAtlasData(atlasText, texture);
this.armatureComponent = UnityFactory.factory.BuildArmatureComponent("Armature");
this.armatureComponent.animation.Play(animation, times);
InvokeRepeating("ReleaseDragon", 3f, 1);
return this.armatureComponent.gameObject;
}
public void ReleaseDragon() {
if (this.armatureComponent == null) {
return;
}
if (!this.armatureComponent.animation.isPlaying) {
DestroyImmediate(this.armatureComponent.gameObject);
UnityFactory.factory.Clear();
this.armatureComponent = null;
}
}
参数解读:
string bonesData 龙骨的json数据
string atlasData 图集数据
string animation 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画)
int times 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1)
UnityFactory.factory.BuildArmatureComponent("Armature")
"Armature" 编辑器里骨架名称
FairyGUI:
GGraph gr = btn.GetChild("mask").asGraph;
GameObject go = PlayLocalPlatform("DB_ske", "DB_tex", "start", 0);
gr.SetNativeObject(new GoWrapper(go));
gr.SetScale(100, 100);
gr.SetXY(194f, 311f);
UGUI待测。。。