阅读 164

Unity3D之龙骨动画事件

Unity3D之龙骨动画事件

using System.Collections;using System.Collections.Generic;using UnityEngine;using DragonBones;public class DragonDemo : MonoBehaviour{
    [SerializeField]
    private UnityArmatureComponent dragon;

    private ListenerDelegate<EventObject> dbDelegate;
    // Start is called before the first frame update
    void Start()
    {
        this.dbDelegate = new ListenerDelegate<EventObject>(this.OnAnimationEventHandler);
        this.dragon.AddEventListener(EventObject.COMPLETE, this.dbDelegate);
        this.dragon.animation.Play("walk", 1);
    }

    private void OnAnimationEventHandler(string type, EventObject obj) {
        Debug.Log("Complete");
    }

    // Update is called once per frame
    void Update()
    {
        
    }}


参考:

        加载
        UnityFactory.factory.LoadDragonBonesData("progress_bar/progress_bar_ske");
        UnityFactory.factory.LoadTextureAtlasData("progress_bar/progress_bar_tex");

        // Build Armature
        this._armatureComp = UnityFactory.factory.BuildArmatureComponent("progress_bar");
        // 添加各种事件
        this._armatureComp.AddDBEventListener(EventObject.START, this.OnAnimationEventHandler);
        this._armatureComp.AddDBEventListener(EventObject.LOOP_COMPLETE, this.OnAnimationEventHandler);
        this._armatureComp.AddDBEventListener(EventObject.COMPLETE, this.OnAnimationEventHandler);
        this._armatureComp.AddDBEventListener(EventObject.FADE_IN, this.OnAnimationEventHandler);
        this._armatureComp.AddDBEventListener(EventObject.FADE_IN_COMPLETE, this.OnAnimationEventHandler);
        this._armatureComp.AddDBEventListener(EventObject.FADE_OUT, this.OnAnimationEventHandler);
        this._armatureComp.AddDBEventListener(EventObject.FADE_OUT_COMPLETE, this.OnAnimationEventHandler);
        this._armatureComp.AddDBEventListener(EventObject.FRAME_EVENT, this.OnAnimationEventHandler);
        //播放
        this._armatureComp.animation.Play("idle");


©著作权归作者所有:来自51CTO博客作者Aonaufly的原创作品,如需转载,请注明出处,否则将追究法律责任


文章分类
后端
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐