Exemple #1
0
        public void Update()
        {
            if (this.m_ControllerIsDirty)
            {
                this.Reset();
            }
            int recursiveBlendParameterCount = this.m_BlendTree.recursiveBlendParameterCount;

            if (this.m_Controller.parameters.Length >= recursiveBlendParameterCount)
            {
                for (int i = 0; i < recursiveBlendParameterCount; i++)
                {
                    string recursiveBlendParameter = this.m_BlendTree.GetRecursiveBlendParameter(i);
                    float  parameterValue          = BlendTreeInspector.GetParameterValue(this.animator, this.m_BlendTree, recursiveBlendParameter);
                    this.animator.SetFloat(recursiveBlendParameter, parameterValue);
                }
                this.animator.EvaluateController();
            }
        }
 private void UpdateAvatarState()
 {
     if (Event.current.type == EventType.Repaint)
     {
         if (this.m_AvatarPreview.PreviewObject == null || this.m_ControllerIsDirty)
         {
             this.m_AvatarPreview.ResetPreviewInstance();
             if (this.m_AvatarPreview.PreviewObject)
             {
                 this.ResetStateMachine();
             }
         }
         if (this.m_AvatarPreview.Animator)
         {
             if (this.m_PrevIKOnFeet != this.m_AvatarPreview.IKOnFeet)
             {
                 this.m_PrevIKOnFeet = this.m_AvatarPreview.IKOnFeet;
                 Vector3    rootPosition = this.m_AvatarPreview.Animator.rootPosition;
                 Quaternion rootRotation = this.m_AvatarPreview.Animator.rootRotation;
                 this.ResetStateMachine();
                 this.m_AvatarPreview.Animator.Update(this.m_AvatarPreview.timeControl.currentTime);
                 this.m_AvatarPreview.Animator.Update(0f);
                 this.m_AvatarPreview.Animator.rootPosition = rootPosition;
                 this.m_AvatarPreview.Animator.rootRotation = rootRotation;
             }
             if (this.m_AvatarPreview.Animator)
             {
                 for (int i = 0; i < this.m_BlendTree.recursiveBlendParameterCount; i++)
                 {
                     string recursiveBlendParameter = this.m_BlendTree.GetRecursiveBlendParameter(i);
                     float  parameterValue          = BlendTreeInspector.GetParameterValue(this.m_AvatarPreview.Animator, this.m_BlendTree, recursiveBlendParameter);
                     this.m_AvatarPreview.Animator.SetFloat(recursiveBlendParameter, parameterValue);
                 }
             }
             this.m_AvatarPreview.timeControl.loop = true;
             float num  = 1f;
             float num2 = 0f;
             if (this.m_AvatarPreview.Animator.layerCount > 0)
             {
                 AnimatorStateInfo currentAnimatorStateInfo = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(0);
                 num  = currentAnimatorStateInfo.length;
                 num2 = currentAnimatorStateInfo.normalizedTime;
             }
             this.m_AvatarPreview.timeControl.startTime = 0f;
             this.m_AvatarPreview.timeControl.stopTime  = num;
             this.m_AvatarPreview.timeControl.Update();
             float num3 = this.m_AvatarPreview.timeControl.deltaTime;
             if (!this.m_BlendTree.isLooping)
             {
                 if (num2 >= 1f)
                 {
                     num3 -= num;
                 }
                 else if (num2 < 0f)
                 {
                     num3 += num;
                 }
             }
             this.m_AvatarPreview.Animator.Update(num3);
         }
     }
 }