Example #1
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (_animation == null)
        {
            _animation = animator.GetComponent <SpriteAnimation>();
        }

        _animation.StopAll();
        _animation.Play(Clip.name);
        _animation.CalculateData();
        _startTime = Time.time;
        if (_state == null)
        {
            _state = _animation[Clip.name];
        }

        _length = _animation[Clip.name].length * (_state.wrapMode == WrapMode.PingPong ? 2 : 1);
        _isLoop = _state.wrapMode == WrapMode.Loop || _state.wrapMode == WrapMode.PingPong;
    }