龍骨官網
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待測。。。