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; } }
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; } }
//////////////////////// 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(); }; } }