animator倒放与正放

animator倒放与正放

/// 
      /// 播放一个动画 1是正常-1倒放
      /// 
      /// 动画片段
      /// 播放速度
      /// 等待时间隐藏
    public void PlayAnim(Animator anim, float speed)
    {
        if (anim != null)
        {
            anim.transform.parent.gameObject.SetActive(true);
            anim.enabled = true;
            AnimatorClipInfo[] temps = anim.GetCurrentAnimatorClipInfo(0);
            AnimatorClipInfo clipInfo = new AnimatorClipInfo();
            if (temps.Length > 0)
            {
                clipInfo = temps[0];//获取动画clip
            }
            anim.StartPlayback();
            anim.speed = speed;
            anim.Play(clipInfo.clip.name, 0, speed < 0 ? 1 : 0);
        }

    }

你可能感兴趣的:(unity,动画,css3,前端)