public void AddEventCallback(float time, AnimationEventCallback callback) { // Only one key one value if (_animationEventCallbackList.ContainsKey(time)) { return; } _animationEventCallbackList[time] = callback; }
public void AddEvent(string anim, float time, AnimationEventCallback callback, object token) { var state = this.States[anim]; if (state == null) { throw new UnknownStateException(name); } state.AddEvent(time, callback, token); }
public void AddAnimationEvent(string animationName, float time, OnAnimationEventFunction callbackFunction) { if (_animationComponent == null) { return; } if (_animationComponent[animationName] == null) { return; } // AnimationEvent animEvent = new AnimationEvent(); // animEvent.time = time; // animEvent.functionName = functionName; // _currentAnimationState.clip.AddEvent(animEvent); // Is same with // this.gameObject.SendMessage(animEvent.functionName, animEvent); if (!_animationStateSlotList.ContainsKey(animationName)) { return; } AnimationStateSlot animStateSlot = _animationStateSlotList[animationName]; // Create new event callback AnimationEventCallback callback = new AnimationEventCallback(); callback._triggerTime = time; callback._onAnimationEventFunction = callbackFunction; callback._userData = animStateSlot; callback._isTriggered = false; callback._isEndEvent = false; // Check is animation end event if (_animationComponent[animationName].length == time) { callback._isEndEvent = true; } // Add the time event into callback list animStateSlot.AddEventCallback(callback._triggerTime, callback); }
internal void CreateAnimationEvent(AnimationClip clip, float time, AnimationEventCallback callback, object token) { //TODO - just realized, this might actually create multiple events on the same clip if 2 different gameobjects call to add it... not sure if 'AnimationClip' is a shared asset or not. Need to test! var ev = new AnimationEvent(); ev.time = time; ev.functionName = "SPAnimationEventHook33417"; ev.stringParameter = ShortUid.NewId().ToString(); if (_animEventTable == null) { _animEventTable = new Dictionary <string, AnimationCallbackData>(); } _animEventTable.Add(ev.stringParameter, new AnimationCallbackData(callback, token)); clip.AddEvent(ev); }
public void AddEvent(float time, AnimationEventCallback callback, object token) { if (_controller == null) { throw new System.InvalidOperationException("This clip has not been initialized."); } if (callback == null) { throw new System.ArgumentNullException("callback"); } if (_clip is AnimationClip) { _controller.CreateAnimationEvent(_clip as AnimationClip, time, callback, token); } else { throw new System.InvalidOperationException("ISPAnimationClip does not support AddEvent."); } }
public AnimationCallbackData(AnimationEventCallback callback, object token) { this.Callback = callback; this.Token = token; }