public static void Play(this ISPAnim anim, float speed, QueueMode queueMode = QueueMode.PlayNow, PlayMode playMode = PlayMode.StopSameLayer) { if (anim == null) { throw new System.ArgumentNullException("anim"); } anim.Speed = speed; anim.Play(queueMode, playMode); }
public bool Trigger(object sender, object arg, BlockingTriggerYieldInstruction instruction) { if (!_useAsBlockingYieldInstruction || instruction == null) { return(this.Trigger(sender, arg)); } if (!this.CanTrigger) { return(false); } var anim = _targetAnimator.GetTarget <ISPAnimationSource>(arg); if (anim == null) { return(false); } var id = _clipIDs.PickRandom(); _currentAnimState = anim.GetAnim(id); if (_currentAnimState == null) { //this.Invoke(() => { this.OnAnimCompleteCallback(null); }, 0f); if (_triggerCompleteIfNoAnim) { this.Invoke(() => { _onAnimComplete.ActivateTrigger(this, arg); }, 0f); } return(false); } instruction.BeginBlock(); _currentAnimState.TimeSupplier = _timeSupplier.TimeSupplier; _currentAnimState.Play(_speed, _startTime, QueueMode.PlayNow, _playMode); _currentAnimState.Schedule((s) => { _currentAnimState = null; if (_daisyChainBlockingYieldInstruction) { _onAnimComplete.DaisyChainTriggerYielding(this, arg, instruction); } else { _onAnimComplete.ActivateTrigger(this, arg); } instruction.EndBlock(); }); return(true); }
public override bool Trigger(object sender, object arg) { if (!this.CanTrigger) { return(false); } var anim = _targetAnimator.GetTarget <ISPAnimationSource>(arg); if (anim == null || !anim.CanPlayAnim) { return(false); } var id = _clipIDs.PickRandom(); _currentAnimState = anim.GetAnim(id); if (_currentAnimState == null) { //this.Invoke(() => { this.OnAnimCompleteCallback(null); }, 0f); if (_triggerCompleteIfNoAnim) { this.Invoke(() => { _onAnimComplete.ActivateTrigger(this, arg); }, 0f); } return(false); } _currentAnimState.TimeSupplier = _timeSupplier.TimeSupplier; _currentAnimState.Play(_speed, _startTime, QueueMode.PlayNow, _playMode); _currentAnimState.Schedule((s) => { _currentAnimState = null; _onAnimComplete.ActivateTrigger(this, arg); }); return(true); }