/// <summary> /// When binding exits active state all effects are stopped. /// </summary> public void Exit(LayerInfo li) { li.controller.Trace("AnimatorStateBinding.Exit: {0}", stateName); if (!string.IsNullOrEmpty(exitMessage)) { li.controller.gameObject.SendMessage(exitMessage, li, SendMessageOptions.RequireReceiver); } System.Array.ForEach(effects, effect => effect.Stop(li)); }
/// <summary> /// Stops playing the effect. /// </summary> public void Stop(LayerInfo li) { if (instance == null) { return; } //if(!instance.activeSelf) return; if (stopTrigger) { return; } stopTrigger = true; playTrigger = false; stopTimestamp = Time.time; StopOrTail(li); }
/// <summary> /// Plays the effect or tails it according to delay. /// </summary> private void StopOrTail(LayerInfo li) { if (playTrigger || !stopTrigger) { return; } var time = Time.time - stopTimestamp; if (time >= stopDelay) { li.controller.Trace("StopOrTail >> Stop {0} {1}", instance, time); instance.SetActive(false); } else { li.controller.Trace("StopOrTail >> Tail {0} {1}", instance, time); li.controller.Tail(() => StopOrTail(li)); } }
/// <summary> /// Tries to provide good default values and allows reuse of this instance. /// </summary> private void Reset() { if (animator == null) { animator = GetComponent <Animator>(); } if (animator != null) { layerState = new LayerInfo[animator.layerCount]; for (var i = 0; i < layerState.Length; i++) { layerState[i] = new LayerInfo(this); } foreach (var binding in bindings) { binding.Reset(); } } // TODO Following lines will cause a wired exception when called from within acivating bindig or effects being tailed. activeBindings.Clear(); tail.Clear(); tailCopy.Clear(); }