unity 嵌入龙骨动画

龙骨官网

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待测。。。

 

附:

在Unity中使用龙骨动画 
终于回到正题了,首先在场景中创建一个DragonBones Armature Object, 导入龙骨的插件后可以在Hierarchy视图中右键看到DragonkBones这个选项,点击Armature Object 
这里写图片描述

创建成功,选中这个Armature对象,查看Inspector视图 

è¿éåå¾çæè¿°

这个对象自带一个UnityArmatureComponent组件,这个组件下有一个叫做龙骨数据(DragonBonesData)的属性,我们刚刚导出到项目里的龙骨动画明明是三个文件,这要怎么办呢? 
在Unity的文件管理器中找到我们导出的龙骨动画的三个文件,将三个文件选中,右键Create->DragonBones->Create Unity Date 
 

龙骨动画相关链接

http://www.manew.com/thread-96726-1-1.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值