示例#1
0
        public static void AddCustomEvent(GameObject gameObject, string clipName, float time, string tag, AnimationClipEventCallback1 action)
        {
            var clip = GetAnimationClip(gameObject, clipName);

            if (clip != null)
            {
                var callbackComp = GetOrAddCallbackComponent(gameObject);
                var evt          = AnimationClipEventCenter.GetInstance().AddClipEvent(clip, time, CUSTOM_FUNCNAME);
                evt.stringParameter    = tag;
                callbackComp.onCustom += action;
            }
        }
示例#2
0
        public static void AddCustomEvent(GameObject gameObject, string clipName, float time, Object obj, AnimationClipEventCallback1Ex action)
        {
            var clip = GetAnimationClip(gameObject, clipName);

            if (clip != null)
            {
                var callbackComp = GetOrAddCallbackComponent(gameObject);
                var evt          = AnimationClipEventCenter.GetInstance().AddClipEvent(clip, time, CUSTOMEX_FUNCNAME);
                evt.objectReferenceParameter = obj;
                callbackComp.onCustomEx     += action;
            }
        }
示例#3
0
        ////////////////////////
        public static void AddCompletedEvent(GameObject gameObject, string clipName, AnimationClipEventCallback0 action)
        {
            var animator = GetAnimator(gameObject);
            var clip     = GetAnimationClip(animator, clipName);

            if (clip != null)
            {
                var callbackComp = GetOrAddCallbackComponent(gameObject);
                AnimationClipEventCenter.GetInstance().AddClipEvent(clip, clip.length, COMPLETED_FUNCNAME);
                callbackComp.onCompleted += () => {
                    if (clip.isLooping)
                    {
                        return;
                    }
                    if (animator.IsInTransition(0))
                    {
                        return;
                    }
                    action?.Invoke();
                };
            }
        }