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的原创作品,如需转载,请注明出处,否则将追究法律责任