Inheritance: AnimatorTransitionBase
Ejemplo n.º 1
0
        public AnimatorStateTransition AddAnyStateTransition(AnimatorStateMachine destinationStateMachine)
        {
            AnimatorStateTransition animatorStateTransition = this.AddAnyStateTransition();

            animatorStateTransition.destinationStateMachine = destinationStateMachine;
            return(animatorStateTransition);
        }
Ejemplo n.º 2
0
        public AnimatorStateTransition AddAnyStateTransition(AnimatorState destinationState)
        {
            AnimatorStateTransition transition = this.AddAnyStateTransition();

            transition.destinationState = destinationState;
            return(transition);
        }
Ejemplo n.º 3
0
        public AnimatorStateTransition AddAnyStateTransition(AnimatorStateMachine destinationStateMachine)
        {
            AnimatorStateTransition newTransition = AddAnyStateTransition();

            newTransition.destinationStateMachine = destinationStateMachine;
            return(newTransition);
        }
Ejemplo n.º 4
0
        public AnimatorStateTransition AddTransition(AnimatorState destinationState)
        {
            AnimatorStateTransition animatorStateTransition = this.AddTransition();

            animatorStateTransition.destinationState = destinationState;
            return(animatorStateTransition);
        }
Ejemplo n.º 5
0
 public void AddTransition(AnimatorStateTransition transition)
 {
     this.undoHandler.DoUndo(this, "Transition added");
     AnimatorStateTransition[] transitions = this.transitions;
     ArrayUtility.Add <AnimatorStateTransition>(ref transitions, transition);
     this.transitions = transitions;
 }
Ejemplo n.º 6
0
 /// <summary>
 ///   <para>Utility function to remove an AnyState transition from the state machine.</para>
 /// </summary>
 /// <param name="transition">The AnyStat transition to remove.</param>
 public bool RemoveAnyStateTransition(AnimatorStateTransition transition)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: variable of a compiler-generated type
     AnimatorStateMachine.\u003CRemoveAnyStateTransition\u003Ec__AnonStorey18 transitionCAnonStorey18 = new AnimatorStateMachine.\u003CRemoveAnyStateTransition\u003Ec__AnonStorey18();
     // ISSUE: reference to a compiler-generated field
     transitionCAnonStorey18.transition = transition;
     // ISSUE: reference to a compiler-generated method
     if (!new List <AnimatorStateTransition>((IEnumerable <AnimatorStateTransition>) this.anyStateTransitions).Any <AnimatorStateTransition>(new Func <AnimatorStateTransition, bool>(transitionCAnonStorey18.\u003C\u003Em__20)))
     {
         return(false);
     }
     this.undoHandler.DoUndo((UnityEngine.Object) this, "AnyState Transition Removed");
     AnimatorStateTransition[] stateTransitions = this.anyStateTransitions;
     // ISSUE: reference to a compiler-generated field
     ArrayUtility.Remove <AnimatorStateTransition>(ref stateTransitions, transitionCAnonStorey18.transition);
     this.anyStateTransitions = stateTransitions;
     // ISSUE: reference to a compiler-generated field
     if (MecanimUtilities.AreSameAsset((UnityEngine.Object) this, (UnityEngine.Object)transitionCAnonStorey18.transition))
     {
         // ISSUE: reference to a compiler-generated field
         Undo.DestroyObjectImmediate((UnityEngine.Object)transitionCAnonStorey18.transition);
     }
     return(true);
 }
Ejemplo n.º 7
0
        public AnimatorStateTransition AddTransition(AnimatorStateMachine destinationStateMachine)
        {
            AnimatorStateTransition transition = this.AddTransition();

            transition.destinationStateMachine = destinationStateMachine;
            return(transition);
        }
Ejemplo n.º 8
0
        public AnimatorStateTransition AddExitTransition()
        {
            AnimatorStateTransition transition = this.AddTransition();

            transition.isExit = true;
            return(transition);
        }
Ejemplo n.º 9
0
        private AnimatorStateTransition AddAnyStateTransition()
        {
            undoHandler.DoUndo(this, "AnyState Transition Added");

            AnimatorStateTransition[] transitionsVector = anyStateTransitions;
            AnimatorStateTransition   newTransition     = new AnimatorStateTransition();

            newTransition.hasExitTime      = false;
            newTransition.hasFixedDuration = true;
            newTransition.duration         = 0.25f;
            newTransition.exitTime         = 0.75f;

            if (AssetDatabase.GetAssetPath(this) != "")
            {
                AssetDatabase.AddObjectToAsset(newTransition, AssetDatabase.GetAssetPath(this));
            }

            undoHandler.DoUndoCreated(newTransition, "AnyState Transition Created");

            newTransition.hideFlags = HideFlags.HideInHierarchy;
            ArrayUtility.Add(ref transitionsVector, newTransition);
            anyStateTransitions = transitionsVector;


            return(newTransition);
        }
Ejemplo n.º 10
0
        public AnimatorStateTransition AddExitTransition(bool defaultExitTime)
        {
            AnimatorStateTransition newTransition = CreateTransition(defaultExitTime);

            newTransition.isExit = true;
            AddTransition(newTransition);
            return(newTransition);
        }
        void BatchChangeProperty(AnimatorStateTransition[] transitions, string property)
        {
            XTomporaryWindow window = InitWindow<XTomporaryWindow>();
            window.OnPaint = () =>
            {

            };
        }
Ejemplo n.º 12
0
        public AnimatorStateTransition AddExitTransition(bool defaultExitTime)
        {
            AnimatorStateTransition animatorStateTransition = this.CreateTransition(defaultExitTime);

            animatorStateTransition.isExit = true;
            this.AddTransition(animatorStateTransition);
            return(animatorStateTransition);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// <para>Utility function to add an outgoing transition to the destination state.</para>
        /// </summary>
        /// <param name="defaultExitTime">If true, the exit time will be the equivalent of 0.25 second.</param>
        /// <param name="destinationState">The destination state.</param>
        public AnimatorStateTransition AddTransition(AnimatorState destinationState, bool defaultExitTime)
        {
            AnimatorStateTransition transition = this.CreateTransition(defaultExitTime);

            transition.destinationState = destinationState;
            this.AddTransition(transition);
            return(transition);
        }
Ejemplo n.º 14
0
        public AnimatorStateTransition AddTransition(AnimatorStateMachine destinationStateMachine, bool defaultExitTime)
        {
            AnimatorStateTransition animatorStateTransition = this.CreateTransition(defaultExitTime);

            animatorStateTransition.destinationStateMachine = destinationStateMachine;
            this.AddTransition(animatorStateTransition);
            return(animatorStateTransition);
        }
Ejemplo n.º 15
0
        public AnimatorStateTransition AddTransition(AnimatorStateMachine destinationStateMachine, bool defaultExitTime)
        {
            AnimatorStateTransition newTransition = CreateTransition(defaultExitTime);

            newTransition.destinationStateMachine = destinationStateMachine;
            AddTransition(newTransition);
            return(newTransition);
        }
Ejemplo n.º 16
0
        public AnimatorStateTransition AddTransition(AnimatorStateMachine destinationStateMachine)
        {
            AnimatorStateTransition animatorStateTransition = this.CreateTransition(false);

            animatorStateTransition.destinationStateMachine = destinationStateMachine;
            this.AddTransition(animatorStateTransition);
            return(animatorStateTransition);
        }
Ejemplo n.º 17
0
        public void AddTransition(AnimatorStateTransition transition)
        {
            undoHandler.DoUndo(this, "Transition added");

            AnimatorStateTransition[] transitionsVector = transitions;
            ArrayUtility.Add(ref transitionsVector, transition);
            transitions = transitionsVector;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// <para>Utility function to add an outgoing transition to the destination state.</para>
        /// </summary>
        /// <param name="defaultExitTime">If true, the exit time will be the equivalent of 0.25 second.</param>
        /// <param name="destinationState">The destination state.</param>
        public AnimatorStateTransition AddTransition(AnimatorState destinationState)
        {
            AnimatorStateTransition transition = this.CreateTransition(false);

            transition.destinationState = destinationState;
            this.AddTransition(transition);
            return(transition);
        }
Ejemplo n.º 19
0
        public AnimatorStateTransition AddTransition(AnimatorStateMachine destinationStateMachine)
        {
            AnimatorStateTransition newTransition = CreateTransition(false);

            newTransition.destinationStateMachine = destinationStateMachine;
            AddTransition(newTransition);
            return(newTransition);
        }
Ejemplo n.º 20
0
        public AnimatorStateTransition AddExitTransition()
        {
            AnimatorStateTransition animatorStateTransition = this.CreateTransition(false);

            animatorStateTransition.isExit = true;
            this.AddTransition(animatorStateTransition);
            return(animatorStateTransition);
        }
Ejemplo n.º 21
0
    private bool compareTranslation(UnityEditor.Animations.AnimatorStateTransition transA, UnityEditor.Animations.AnimatorStateTransition transB)
    {
        if (transA.destinationState.name != transB.destinationState.name)
        {
            return(false);
        }

        if ((transA.hasExitTime && transB.hasExitTime && Mathf.Abs(transA.exitTime - transB.exitTime) < 0.1f) ||
            (!transA.hasExitTime && !transB.hasExitTime))
        {
            //go on
        }
        else
        {
            return(false);
        }

        if (Mathf.Abs(transA.duration - transB.duration) > 0.1f)
        {
            return(false);
        }

        if (transA.conditions != null && transB.conditions != null)
        {
            if (transA.conditions.Length != transB.conditions.Length)
            {
                return(false);
            }

            foreach (var conA in transA.conditions)
            {
                bool found = false;
                foreach (var conB in transB.conditions)
                {
                    if (conA.mode == conB.mode && conA.parameter == conB.parameter && conA.threshold == conB.threshold)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    return(false);
                }
            }
        }
        else if (transA.conditions == null && transB.conditions == null)
        {
            //go on
        }
        else
        {
            return(false);
        }

        return(true);
    }
Ejemplo n.º 22
0
 private void SetDefaultTransitionExitTime(ref AnimatorStateTransition newTransition)
 {
     newTransition.hasExitTime = true;
     if (this.motion != null && this.motion.averageDuration > 0f)
     {
         float num = 0.25f / this.motion.averageDuration;
         newTransition.duration = ((!newTransition.hasFixedDuration) ? num : 0.25f);
         newTransition.exitTime = 1f - num;
     }
 }
Ejemplo n.º 23
0
        public AnimatorStateTransition AddTransition(AnimatorState destinationState, bool defaultExitTime)
        {
            AnimatorStateTransition newTransition = this.AddTransition(destinationState);

            if (defaultExitTime)
            {
                this.SetDefaultTransitionExitTime(ref newTransition);
            }
            return(newTransition);
        }
Ejemplo n.º 24
0
 private void CopyTransitionForPreview(AnimatorStateTransition src, ref AnimatorStateTransition dst)
 {
     if (src != null)
     {
         dst.duration = src.duration;
         dst.offset = src.offset;
         dst.exitTime = src.exitTime;
         dst.hasFixedDuration = src.hasFixedDuration;
     }
 }
Ejemplo n.º 25
0
        public AnimatorStateTransition AddTransition(AnimatorStateMachine destinationStateMachine, bool defaultExitTime)
        {
            AnimatorStateTransition result = this.AddTransition(destinationStateMachine);

            if (defaultExitTime)
            {
                this.SetDefaultTransitionExitTime(ref result);
            }
            return(result);
        }
Ejemplo n.º 26
0
        public AnimatorStateTransition AddExitTransition(bool defaultExitTime)
        {
            AnimatorStateTransition newTransition = this.AddTransition();

            newTransition.isExit = true;
            if (defaultExitTime)
            {
                this.SetDefaultTransitionExitTime(ref newTransition);
            }
            return(newTransition);
        }
Ejemplo n.º 27
0
 public void RemoveTransition(AnimatorStateTransition transition)
 {
     this.undoHandler.DoUndo(this, "Transition removed");
     AnimatorStateTransition[] transitions = this.transitions;
     ArrayUtility.Remove <AnimatorStateTransition>(ref transitions, transition);
     this.transitions = transitions;
     if (MecanimUtilities.AreSameAsset(this, transition))
     {
         Undo.DestroyObjectImmediate(transition);
     }
 }
Ejemplo n.º 28
0
        public AnimatorStateTransition AddExitTransition(bool defaultExitTime)
        {
            AnimatorStateTransition animatorStateTransition = this.CreateTransition(false);

            animatorStateTransition.isExit = true;
            if (defaultExitTime)
            {
                this.SetDefaultTransitionExitTime(ref animatorStateTransition);
            }
            this.AddTransition(animatorStateTransition);
            return(animatorStateTransition);
        }
Ejemplo n.º 29
0
 /// <summary>
 ///   <para>Utility function to remove a transition from the state.</para>
 /// </summary>
 /// <param name="transition">Transition to remove.</param>
 public void RemoveTransition(AnimatorStateTransition transition)
 {
     this.undoHandler.DoUndo((UnityEngine.Object) this, "Transition removed");
     AnimatorStateTransition[] transitions = this.transitions;
     ArrayUtility.Remove <AnimatorStateTransition>(ref transitions, transition);
     this.transitions = transitions;
     if (!MecanimUtilities.AreSameAsset((UnityEngine.Object) this, (UnityEngine.Object)transition))
     {
         return;
     }
     Undo.DestroyObjectImmediate((UnityEngine.Object)transition);
 }
Ejemplo n.º 30
0
        private void SetDefaultTransitionExitTime(ref AnimatorStateTransition newTransition)
        {
            newTransition.hasExitTime = true;
            if (!((UnityEngine.Object) this.motion != (UnityEngine.Object)null) || (double)this.motion.averageDuration <= 0.0)
            {
                return;
            }
            float num = 0.25f / this.motion.averageDuration;

            newTransition.duration = !newTransition.hasFixedDuration ? num : 0.25f;
            newTransition.exitTime = 1f - num;
        }
Ejemplo n.º 31
0
        private AnimatorStateTransition AddTransition()
        {
            AnimatorStateTransition animatorStateTransition = new AnimatorStateTransition();

            animatorStateTransition.hasExitTime = false;
            if (AssetDatabase.GetAssetPath(this) != string.Empty)
            {
                AssetDatabase.AddObjectToAsset(animatorStateTransition, AssetDatabase.GetAssetPath(this));
            }
            animatorStateTransition.hideFlags = HideFlags.HideInHierarchy;
            this.AddTransition(animatorStateTransition);
            return(animatorStateTransition);
        }
Ejemplo n.º 32
0
 internal void RemoveAnyStateTransitionRecursive(AnimatorStateTransition transition)
 {
     if (!this.RemoveAnyStateTransition(transition))
     {
         List <ChildAnimatorStateMachine> stateMachinesRecursive = this.stateMachinesRecursive;
         foreach (ChildAnimatorStateMachine current in stateMachinesRecursive)
         {
             if (current.stateMachine.RemoveAnyStateTransition(transition))
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 33
0
			public void Set(AnimatorStateTransition transition, AnimatorState srcState, AnimatorState dstState)
			{
				if (transition != null)
				{
					this.m_SrcState = srcState;
					this.m_DstState = dstState;
					this.m_TransitionDuration = transition.duration;
					this.m_TransitionOffset = transition.offset;
					this.m_ExitTime = 0.5f;
				}
				else
				{
					this.Init();
				}
			}
Ejemplo n.º 34
0
 private void ClearController()
 {
     if ((this.m_AvatarPreview != null) && (this.m_AvatarPreview.Animator != null))
     {
         AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, null);
     }
     UnityEngine.Object.DestroyImmediate(this.m_Controller);
     UnityEngine.Object.DestroyImmediate(this.m_SrcState);
     UnityEngine.Object.DestroyImmediate(this.m_DstState);
     UnityEngine.Object.DestroyImmediate(this.m_Transition);
     this.m_StateMachine = null;
     this.m_Controller = null;
     this.m_SrcState = null;
     this.m_DstState = null;
     this.m_Transition = null;
 }
 private static extern void Internal_Create(AnimatorStateTransition mono);
 private void CopyTransitionForPreview(AnimatorStateTransition src, ref AnimatorStateTransition dst)
 {
   if (!((UnityEngine.Object) src != (UnityEngine.Object) null))
     return;
   dst.duration = src.duration;
   dst.offset = src.offset;
   dst.exitTime = src.exitTime;
   dst.hasFixedDuration = src.hasFixedDuration;
 }
Ejemplo n.º 37
0
 private void ResampleTransition(AnimatorStateTransition transition, AvatarMask layerMask, TransitionInfo info, Animator previewObject)
 {
     this.m_IsResampling = true;
     this.m_MustResample = false;
     bool flag = this.m_RefTransition != transition;
     this.m_RefTransition = transition;
     this.m_RefTransitionInfo = info;
     this.m_LayerMask = layerMask;
     if (this.m_AvatarPreview != null)
     {
         this.m_AvatarPreview.OnDestroy();
         this.m_AvatarPreview = null;
     }
     this.ClearController();
     Motion motion = this.m_RefSrcState.motion;
     this.Init(previewObject, (motion == null) ? this.m_RefDstState.motion : motion);
     if (this.m_Controller != null)
     {
         this.m_AvatarPreview.Animator.allowConstantClipSamplingOptimization = false;
         this.m_StateMachine.defaultState = this.m_DstState;
         this.m_Transition.mute = true;
         AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
         this.m_AvatarPreview.Animator.Update(1E-05f);
         this.WriteParametersInController();
         this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
         float length = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex).length;
         this.m_StateMachine.defaultState = this.m_SrcState;
         this.m_Transition.mute = false;
         AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
         this.m_AvatarPreview.Animator.Update(1E-05f);
         this.WriteParametersInController();
         this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
         float num2 = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex).length;
         if (this.m_LayerIndex > 0)
         {
             this.m_AvatarPreview.Animator.stabilizeFeet = false;
         }
         float num3 = ((num2 * this.m_RefTransition.exitTime) + (this.m_Transition.duration * (!this.m_RefTransition.hasFixedDuration ? num2 : 1f))) + length;
         if (num3 > 2000f)
         {
             Debug.LogWarning("Transition duration is longer than 2000 second, Disabling previewer.");
             this.m_ValidTransition = false;
         }
         else
         {
             float num4 = (this.m_RefTransition.exitTime <= 0f) ? num2 : (num2 * this.m_RefTransition.exitTime);
             float a = (num4 <= 0f) ? 0.03333334f : Mathf.Min(Mathf.Max((float) (num4 / 300f), (float) 0.03333334f), num4 / 5f);
             float num6 = (length <= 0f) ? 0.03333334f : Mathf.Min(Mathf.Max((float) (length / 300f), (float) 0.03333334f), length / 5f);
             a = Mathf.Max(a, num3 / 300f);
             num6 = Mathf.Max(num6, num3 / 300f);
             float deltaTime = a;
             float num8 = 0f;
             bool flag2 = false;
             bool flag3 = false;
             bool flag4 = false;
             this.m_AvatarPreview.Animator.StartRecording(-1);
             this.m_LeftStateWeightA = 0f;
             this.m_LeftStateTimeA = 0f;
             this.m_AvatarPreview.Animator.Update(0f);
             int num9 = 0;
             while (!flag4)
             {
                 num9++;
                 this.m_AvatarPreview.Animator.Update(deltaTime);
                 AnimatorStateInfo currentAnimatorStateInfo = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex);
                 num8 += deltaTime;
                 if (!flag2)
                 {
                     this.m_LeftStateWeightA = currentAnimatorStateInfo.normalizedTime;
                     this.m_LeftStateTimeA = num8;
                     flag2 = true;
                 }
                 if (flag3 && (num8 >= num3))
                 {
                     flag4 = true;
                 }
                 if (!flag3 && currentAnimatorStateInfo.IsName(this.m_DstState.name))
                 {
                     this.m_RightStateWeightA = currentAnimatorStateInfo.normalizedTime;
                     this.m_RightStateTimeA = num8;
                     flag3 = true;
                 }
                 if (!flag3)
                 {
                     this.m_LeftStateWeightB = currentAnimatorStateInfo.normalizedTime;
                     this.m_LeftStateTimeB = num8;
                 }
                 if (flag3)
                 {
                     this.m_RightStateWeightB = currentAnimatorStateInfo.normalizedTime;
                     this.m_RightStateTimeB = num8;
                 }
                 if (this.m_AvatarPreview.Animator.IsInTransition(this.m_LayerIndex))
                 {
                     deltaTime = num6;
                 }
             }
             float num10 = num8;
             this.m_AvatarPreview.Animator.StopRecording();
             if (Mathf.Approximately(this.m_LeftStateWeightB, this.m_LeftStateWeightA) || Mathf.Approximately(this.m_RightStateWeightB, this.m_RightStateWeightA))
             {
                 Debug.LogWarning("Speed difference between states is too big. Transition preview will be disabled.");
                 this.m_ValidTransition = false;
             }
             else
             {
                 float num11 = (this.m_LeftStateTimeB - this.m_LeftStateTimeA) / (this.m_LeftStateWeightB - this.m_LeftStateWeightA);
                 float num12 = (this.m_RightStateTimeB - this.m_RightStateTimeA) / (this.m_RightStateWeightB - this.m_RightStateWeightA);
                 if (this.m_MustSampleMotions)
                 {
                     this.m_MustSampleMotions = false;
                     this.m_SrcPivotList.Clear();
                     this.m_DstPivotList.Clear();
                     deltaTime = num6;
                     this.m_StateMachine.defaultState = this.m_DstState;
                     this.m_Transition.mute = true;
                     AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
                     this.m_AvatarPreview.Animator.Update(0f);
                     this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
                     this.m_AvatarPreview.Animator.Update(1E-07f);
                     this.WriteParametersInController();
                     for (num8 = 0f; num8 <= num12; num8 += deltaTime * 2f)
                     {
                         Timeline.PivotSample item = new Timeline.PivotSample {
                             m_Time = num8,
                             m_Weight = this.m_AvatarPreview.Animator.pivotWeight
                         };
                         this.m_DstPivotList.Add(item);
                         this.m_AvatarPreview.Animator.Update(deltaTime * 2f);
                     }
                     deltaTime = a;
                     this.m_StateMachine.defaultState = this.m_SrcState;
                     this.m_Transition.mute = true;
                     AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
                     this.m_AvatarPreview.Animator.Update(1E-07f);
                     this.WriteParametersInController();
                     this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
                     for (num8 = 0f; num8 <= num11; num8 += deltaTime * 2f)
                     {
                         Timeline.PivotSample sample2 = new Timeline.PivotSample {
                             m_Time = num8,
                             m_Weight = this.m_AvatarPreview.Animator.pivotWeight
                         };
                         this.m_SrcPivotList.Add(sample2);
                         this.m_AvatarPreview.Animator.Update(deltaTime * 2f);
                     }
                     this.m_Transition.mute = false;
                     AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
                     this.m_AvatarPreview.Animator.Update(1E-07f);
                     this.WriteParametersInController();
                 }
                 this.m_Timeline.StopTime = this.m_AvatarPreview.timeControl.stopTime = num10;
                 this.m_AvatarPreview.timeControl.currentTime = this.m_Timeline.Time;
                 if (flag)
                 {
                     float num13;
                     this.m_AvatarPreview.timeControl.currentTime = num13 = this.m_AvatarPreview.timeControl.startTime = 0f;
                     this.m_Timeline.StartTime = num13;
                     this.m_Timeline.Time = num13;
                     this.m_Timeline.ResetRange();
                 }
                 this.m_AvatarPreview.Animator.StartPlayback();
                 this.m_IsResampling = false;
             }
         }
     }
 }
Ejemplo n.º 38
0
		private void ResampleTransition(AnimatorStateTransition transition, AvatarMask layerMask, TransitionPreview.TransitionInfo info, Animator previewObject)
		{
			this.m_IsResampling = true;
			this.m_MustResample = false;
			bool flag = this.m_RefTransition != transition;
			this.m_RefTransition = transition;
			this.m_RefTransitionInfo = info;
			this.m_LayerMask = layerMask;
			if (this.m_AvatarPreview != null)
			{
				this.m_AvatarPreview.OnDestroy();
				this.m_AvatarPreview = null;
			}
			this.ClearController();
			Motion motion = this.m_RefSrcState.motion;
			this.Init(previewObject, (!(motion != null)) ? this.m_RefDstState.motion : motion);
			if (this.m_Controller == null)
			{
				return;
			}
			this.m_AvatarPreview.Animator.allowConstantClipSamplingOptimization = false;
			this.m_StateMachine.defaultState = this.m_DstState;
			this.m_Transition.mute = true;
			AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
			this.m_AvatarPreview.Animator.Update(1E-05f);
			this.WriteParametersInController();
			this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
			float length = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex).length;
			this.m_StateMachine.defaultState = this.m_SrcState;
			this.m_Transition.mute = false;
			AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
			this.m_AvatarPreview.Animator.Update(1E-05f);
			this.WriteParametersInController();
			this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
			float length2 = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex).length;
			if (this.m_LayerIndex > 0)
			{
				this.m_AvatarPreview.Animator.stabilizeFeet = false;
			}
			float num = length2 * this.m_RefTransition.exitTime + length2 * this.m_Transition.duration + length;
			if (num > 2000f)
			{
				Debug.LogWarning("Transition duration is longer than 2000 second, Disabling previewer.");
				this.m_ValidTransition = false;
				return;
			}
			float num2 = (this.m_RefTransition.exitTime <= 0f) ? length2 : (length2 * this.m_RefTransition.exitTime);
			float num3 = (num2 <= 0f) ? 0.0333333351f : Mathf.Min(Mathf.Max(num2 / 300f, 0.0333333351f), num2 / 5f);
			float num4 = (length <= 0f) ? 0.0333333351f : Mathf.Min(Mathf.Max(length / 300f, 0.0333333351f), length / 5f);
			num3 = Mathf.Max(num3, num / 300f);
			num4 = Mathf.Max(num4, num / 300f);
			float num5 = num3;
			float num6 = 0f;
			bool flag2 = false;
			bool flag3 = false;
			bool flag4 = false;
			this.m_AvatarPreview.Animator.StartRecording(-1);
			this.m_LeftStateWeightA = 0f;
			this.m_LeftStateTimeA = 0f;
			this.m_AvatarPreview.Animator.Update(0f);
			int num7 = 0;
			while (!flag4)
			{
				num7++;
				this.m_AvatarPreview.Animator.Update(num5);
				AnimatorStateInfo currentAnimatorStateInfo = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex);
				num6 += num5;
				if (!flag2)
				{
					this.m_LeftStateWeightA = currentAnimatorStateInfo.normalizedTime;
					this.m_LeftStateTimeA = num6;
					flag2 = true;
				}
				if (flag3 && num6 >= num)
				{
					flag4 = true;
				}
				if (!flag3 && currentAnimatorStateInfo.IsName(this.m_DstState.name))
				{
					this.m_RightStateWeightA = currentAnimatorStateInfo.normalizedTime;
					this.m_RightStateTimeA = num6;
					flag3 = true;
				}
				if (!flag3)
				{
					this.m_LeftStateWeightB = currentAnimatorStateInfo.normalizedTime;
					this.m_LeftStateTimeB = num6;
				}
				if (flag3)
				{
					this.m_RightStateWeightB = currentAnimatorStateInfo.normalizedTime;
					this.m_RightStateTimeB = num6;
				}
				if (this.m_AvatarPreview.Animator.IsInTransition(this.m_LayerIndex))
				{
					num5 = num4;
				}
			}
			float stopTime = num6;
			this.m_AvatarPreview.Animator.StopRecording();
			if (Mathf.Approximately(this.m_LeftStateWeightB, this.m_LeftStateWeightA) || Mathf.Approximately(this.m_RightStateWeightB, this.m_RightStateWeightA))
			{
				Debug.LogWarning("Speed difference between states is too big. Transition preview will be disabled.");
				this.m_ValidTransition = false;
				return;
			}
			float num8 = (this.m_LeftStateTimeB - this.m_LeftStateTimeA) / (this.m_LeftStateWeightB - this.m_LeftStateWeightA);
			float num9 = (this.m_RightStateTimeB - this.m_RightStateTimeA) / (this.m_RightStateWeightB - this.m_RightStateWeightA);
			if (this.m_MustSampleMotions)
			{
				this.m_MustSampleMotions = false;
				this.m_SrcPivotList.Clear();
				this.m_DstPivotList.Clear();
				num5 = num4;
				this.m_StateMachine.defaultState = this.m_DstState;
				this.m_Transition.mute = true;
				AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
				this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
				this.m_AvatarPreview.Animator.Update(1E-07f);
				this.WriteParametersInController();
				num6 = 0f;
				while (num6 <= num9)
				{
					this.m_AvatarPreview.Animator.Update(num5 * 2f);
					num6 += num5 * 2f;
					Timeline.PivotSample pivotSample = new Timeline.PivotSample();
					pivotSample.m_Time = num6;
					pivotSample.m_Weight = this.m_AvatarPreview.Animator.pivotWeight;
					this.m_DstPivotList.Add(pivotSample);
				}
				num5 = num3;
				this.m_StateMachine.defaultState = this.m_SrcState;
				this.m_Transition.mute = true;
				AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
				this.m_AvatarPreview.Animator.Update(1E-07f);
				this.WriteParametersInController();
				this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
				num6 = 0f;
				while (num6 <= num8)
				{
					this.m_AvatarPreview.Animator.Update(num5 * 2f);
					num6 += num5 * 2f;
					Timeline.PivotSample pivotSample2 = new Timeline.PivotSample();
					pivotSample2.m_Time = num6;
					pivotSample2.m_Weight = this.m_AvatarPreview.Animator.pivotWeight;
					this.m_SrcPivotList.Add(pivotSample2);
				}
				this.m_Transition.mute = false;
				AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
				this.m_AvatarPreview.Animator.Update(1E-07f);
				this.WriteParametersInController();
			}
			this.m_Timeline.StopTime = (this.m_AvatarPreview.timeControl.stopTime = stopTime);
			this.m_AvatarPreview.timeControl.currentTime = this.m_Timeline.Time;
			if (flag)
			{
				Timeline arg_74F_0 = this.m_Timeline;
				float num10 = this.m_AvatarPreview.timeControl.currentTime = (this.m_AvatarPreview.timeControl.startTime = 0f);
				this.m_Timeline.StartTime = num10;
				arg_74F_0.Time = num10;
				this.m_Timeline.ResetRange();
			}
			this.m_AvatarPreview.Animator.StartPlayback();
			this.m_IsResampling = false;
		}
Ejemplo n.º 39
0
 public void SetTransition(AnimatorStateTransition transition, AnimatorState sourceState, AnimatorState destinationState, AnimatorControllerLayer srcLayer, Animator previewObject)
 {
     this.m_RefSrcState = sourceState;
     this.m_RefDstState = destinationState;
     TransitionInfo info = new TransitionInfo();
     info.Set(transition, sourceState, destinationState);
     if (this.MustResample(info))
     {
         this.ResampleTransition(transition, srcLayer.avatarMask, info, previewObject);
     }
 }
Ejemplo n.º 40
0
		private void CreateController()
		{
			if (this.m_Controller == null && this.m_AvatarPreview != null && this.m_AvatarPreview.Animator != null && this.m_RefTransition != null)
			{
				this.m_LayerIndex = 0;
				this.m_Controller = new AnimatorController();
				this.m_Controller.pushUndo = false;
				this.m_Controller.hideFlags = HideFlags.HideAndDontSave;
				this.m_Controller.AddLayer("preview");
				bool flag = true;
				if (this.m_LayerMask != null)
				{
					int humanoidBodyPartCount = this.m_LayerMask.humanoidBodyPartCount;
					int num = 0;
					while (num < humanoidBodyPartCount && flag)
					{
						if (!this.m_LayerMask.GetHumanoidBodyPartActive(num))
						{
							flag = false;
						}
						num++;
					}
					if (!flag)
					{
						this.m_Controller.AddLayer("Additionnal");
						this.m_LayerIndex++;
						AnimatorControllerLayer[] layers = this.m_Controller.layers;
						layers[this.m_LayerIndex].avatarMask = this.m_LayerMask;
						this.m_Controller.layers = layers;
					}
				}
				this.m_StateMachine = this.m_Controller.layers[this.m_LayerIndex].stateMachine;
				this.m_StateMachine.pushUndo = false;
				this.m_StateMachine.hideFlags = HideFlags.HideAndDontSave;
				this.m_SrcMotion = this.m_RefSrcState.motion;
				this.m_DstMotion = this.m_RefDstState.motion;
				this.m_ParameterMinMax.Clear();
				if (this.m_SrcMotion && this.m_SrcMotion is BlendTree)
				{
					BlendTree blendTree = this.m_SrcMotion as BlendTree;
					for (int i = 0; i < blendTree.recursiveBlendParameterCount; i++)
					{
						string recursiveBlendParameter = blendTree.GetRecursiveBlendParameter(i);
						if (this.m_Controller.IndexOfParameter(recursiveBlendParameter) == -1)
						{
							this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float);
							this.m_ParameterMinMax.Add(new Vector2(blendTree.GetRecursiveBlendParameterMin(i), blendTree.GetRecursiveBlendParameterMax(i)));
						}
					}
				}
				if (this.m_DstMotion && this.m_DstMotion is BlendTree)
				{
					BlendTree blendTree2 = this.m_DstMotion as BlendTree;
					for (int j = 0; j < blendTree2.recursiveBlendParameterCount; j++)
					{
						string recursiveBlendParameter2 = blendTree2.GetRecursiveBlendParameter(j);
						int num2 = this.m_Controller.IndexOfParameter(recursiveBlendParameter2);
						if (num2 == -1)
						{
							this.m_Controller.AddParameter(recursiveBlendParameter2, AnimatorControllerParameterType.Float);
							this.m_ParameterMinMax.Add(new Vector2(blendTree2.GetRecursiveBlendParameterMin(j), blendTree2.GetRecursiveBlendParameterMax(j)));
						}
						else
						{
							this.m_ParameterMinMax[num2] = new Vector2(Mathf.Min(blendTree2.GetRecursiveBlendParameterMin(j), this.m_ParameterMinMax[num2][0]), Mathf.Max(blendTree2.GetRecursiveBlendParameterMax(j), this.m_ParameterMinMax[num2][1]));
						}
					}
				}
				this.m_SrcState = this.m_StateMachine.AddState(this.m_RefSrcState.name);
				this.m_SrcState.pushUndo = false;
				this.m_SrcState.hideFlags = HideFlags.HideAndDontSave;
				this.m_DstState = this.m_StateMachine.AddState(this.m_RefDstState.name);
				this.m_DstState.pushUndo = false;
				this.m_DstState.hideFlags = HideFlags.HideAndDontSave;
				this.CopyStateForPreview(this.m_RefSrcState, ref this.m_SrcState);
				this.CopyStateForPreview(this.m_RefDstState, ref this.m_DstState);
				this.m_Transition = this.m_SrcState.AddTransition(this.m_DstState, true);
				this.m_Transition.pushUndo = false;
				this.m_Transition.hideFlags = HideFlags.DontSave;
				this.CopyTransitionForPreview(this.m_RefTransition, ref this.m_Transition);
				this.DisableIKOnFeetIfNeeded();
				AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
				AnimatorController expr_400 = this.m_Controller;
				expr_400.OnAnimatorControllerDirty = (Action)Delegate.Combine(expr_400.OnAnimatorControllerDirty, new Action(this.ControllerDirty));
			}
		}
Ejemplo n.º 41
0
 private void CreateController()
 {
     if (((this.m_Controller == null) && (this.m_AvatarPreview != null)) && ((this.m_AvatarPreview.Animator != null) && (this.m_RefTransition != null)))
     {
         this.m_LayerIndex = 0;
         this.m_Controller = new AnimatorController();
         this.m_Controller.pushUndo = false;
         this.m_Controller.hideFlags = HideFlags.HideAndDontSave;
         this.m_Controller.AddLayer("preview");
         bool flag = true;
         if (this.m_LayerMask != null)
         {
             int humanoidBodyPartCount = this.m_LayerMask.humanoidBodyPartCount;
             for (int i = 0; (i < humanoidBodyPartCount) && flag; i++)
             {
                 if (!this.m_LayerMask.GetHumanoidBodyPartActive(i))
                 {
                     flag = false;
                 }
             }
             if (!flag)
             {
                 this.m_Controller.AddLayer("Additionnal");
                 this.m_LayerIndex++;
                 AnimatorControllerLayer[] layers = this.m_Controller.layers;
                 layers[this.m_LayerIndex].avatarMask = this.m_LayerMask;
                 this.m_Controller.layers = layers;
             }
         }
         this.m_StateMachine = this.m_Controller.layers[this.m_LayerIndex].stateMachine;
         this.m_StateMachine.pushUndo = false;
         this.m_StateMachine.hideFlags = HideFlags.HideAndDontSave;
         this.m_SrcMotion = this.m_RefSrcState.motion;
         this.m_DstMotion = this.m_RefDstState.motion;
         this.m_ParameterMinMax.Clear();
         if ((this.m_SrcMotion != null) && (this.m_SrcMotion is BlendTree))
         {
             BlendTree srcMotion = this.m_SrcMotion as BlendTree;
             for (int j = 0; j < srcMotion.recursiveBlendParameterCount; j++)
             {
                 string recursiveBlendParameter = srcMotion.GetRecursiveBlendParameter(j);
                 if (this.m_Controller.IndexOfParameter(recursiveBlendParameter) == -1)
                 {
                     this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float);
                     this.m_ParameterMinMax.Add(new Vector2(srcMotion.GetRecursiveBlendParameterMin(j), srcMotion.GetRecursiveBlendParameterMax(j)));
                 }
             }
         }
         if ((this.m_DstMotion != null) && (this.m_DstMotion is BlendTree))
         {
             BlendTree dstMotion = this.m_DstMotion as BlendTree;
             for (int k = 0; k < dstMotion.recursiveBlendParameterCount; k++)
             {
                 string name = dstMotion.GetRecursiveBlendParameter(k);
                 int num5 = this.m_Controller.IndexOfParameter(name);
                 if (num5 == -1)
                 {
                     this.m_Controller.AddParameter(name, AnimatorControllerParameterType.Float);
                     this.m_ParameterMinMax.Add(new Vector2(dstMotion.GetRecursiveBlendParameterMin(k), dstMotion.GetRecursiveBlendParameterMax(k)));
                 }
                 else
                 {
                     Vector2 vector = this.m_ParameterMinMax[num5];
                     Vector2 vector2 = this.m_ParameterMinMax[num5];
                     this.m_ParameterMinMax[num5] = new Vector2(Mathf.Min(dstMotion.GetRecursiveBlendParameterMin(k), vector[0]), Mathf.Max(dstMotion.GetRecursiveBlendParameterMax(k), vector2[1]));
                 }
             }
         }
         this.m_SrcState = this.m_StateMachine.AddState(this.m_RefSrcState.name);
         this.m_SrcState.pushUndo = false;
         this.m_SrcState.hideFlags = HideFlags.HideAndDontSave;
         this.m_DstState = this.m_StateMachine.AddState(this.m_RefDstState.name);
         this.m_DstState.pushUndo = false;
         this.m_DstState.hideFlags = HideFlags.HideAndDontSave;
         this.CopyStateForPreview(this.m_RefSrcState, ref this.m_SrcState);
         this.CopyStateForPreview(this.m_RefDstState, ref this.m_DstState);
         this.m_Transition = this.m_SrcState.AddTransition(this.m_DstState, true);
         this.m_Transition.pushUndo = false;
         this.m_Transition.hideFlags = HideFlags.DontSave;
         this.CopyTransitionForPreview(this.m_RefTransition, ref this.m_Transition);
         this.DisableIKOnFeetIfNeeded();
         AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
         this.m_Controller.OnAnimatorControllerDirty = (System.Action) Delegate.Combine(this.m_Controller.OnAnimatorControllerDirty, new System.Action(this.ControllerDirty));
     }
 }
Ejemplo n.º 42
0
 public void clear()
 {
     m_condList.Clear();
     m_animatorStateTransition = null;
 }
 private void CreateController()
 {
   if (!((UnityEngine.Object) this.m_Controller == (UnityEngine.Object) null) || this.m_AvatarPreview == null || (!((UnityEngine.Object) this.m_AvatarPreview.Animator != (UnityEngine.Object) null) || !((UnityEngine.Object) this.m_RefTransition != (UnityEngine.Object) null)))
     return;
   this.m_LayerIndex = 0;
   this.m_Controller = new AnimatorController();
   this.m_Controller.pushUndo = false;
   this.m_Controller.hideFlags = HideFlags.HideAndDontSave;
   this.m_Controller.AddLayer("preview");
   bool flag = true;
   if ((UnityEngine.Object) this.m_LayerMask != (UnityEngine.Object) null)
   {
     for (AvatarMaskBodyPart index = AvatarMaskBodyPart.Root; index < AvatarMaskBodyPart.LastBodyPart && flag; ++index)
     {
       if (!this.m_LayerMask.GetHumanoidBodyPartActive(index))
         flag = false;
     }
     if (!flag)
     {
       this.m_Controller.AddLayer("Additionnal");
       ++this.m_LayerIndex;
       AnimatorControllerLayer[] layers = this.m_Controller.layers;
       layers[this.m_LayerIndex].avatarMask = this.m_LayerMask;
       this.m_Controller.layers = layers;
     }
   }
   this.m_StateMachine = this.m_Controller.layers[this.m_LayerIndex].stateMachine;
   this.m_StateMachine.pushUndo = false;
   this.m_StateMachine.hideFlags = HideFlags.HideAndDontSave;
   this.m_SrcMotion = this.m_RefSrcState.motion;
   this.m_DstMotion = this.m_RefDstState.motion;
   this.m_ParameterMinMax.Clear();
   if ((bool) ((UnityEngine.Object) this.m_SrcMotion) && this.m_SrcMotion is BlendTree)
   {
     BlendTree srcMotion = this.m_SrcMotion as BlendTree;
     for (int index = 0; index < srcMotion.recursiveBlendParameterCount; ++index)
     {
       string recursiveBlendParameter = srcMotion.GetRecursiveBlendParameter(index);
       if (this.m_Controller.IndexOfParameter(recursiveBlendParameter) == -1)
       {
         this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float);
         this.m_ParameterMinMax.Add(new Vector2(srcMotion.GetRecursiveBlendParameterMin(index), srcMotion.GetRecursiveBlendParameterMax(index)));
       }
     }
   }
   if ((bool) ((UnityEngine.Object) this.m_DstMotion) && this.m_DstMotion is BlendTree)
   {
     BlendTree dstMotion = this.m_DstMotion as BlendTree;
     for (int index1 = 0; index1 < dstMotion.recursiveBlendParameterCount; ++index1)
     {
       string recursiveBlendParameter = dstMotion.GetRecursiveBlendParameter(index1);
       int index2 = this.m_Controller.IndexOfParameter(recursiveBlendParameter);
       if (index2 == -1)
       {
         this.m_Controller.AddParameter(recursiveBlendParameter, AnimatorControllerParameterType.Float);
         this.m_ParameterMinMax.Add(new Vector2(dstMotion.GetRecursiveBlendParameterMin(index1), dstMotion.GetRecursiveBlendParameterMax(index1)));
       }
       else
         this.m_ParameterMinMax[index2] = new Vector2(Mathf.Min(dstMotion.GetRecursiveBlendParameterMin(index1), this.m_ParameterMinMax[index2][0]), Mathf.Max(dstMotion.GetRecursiveBlendParameterMax(index1), this.m_ParameterMinMax[index2][1]));
     }
   }
   this.m_SrcState = this.m_StateMachine.AddState(this.m_RefSrcState.name);
   this.m_SrcState.pushUndo = false;
   this.m_SrcState.hideFlags = HideFlags.HideAndDontSave;
   this.m_DstState = this.m_StateMachine.AddState(this.m_RefDstState.name);
   this.m_DstState.pushUndo = false;
   this.m_DstState.hideFlags = HideFlags.HideAndDontSave;
   this.CopyStateForPreview(this.m_RefSrcState, ref this.m_SrcState);
   this.CopyStateForPreview(this.m_RefDstState, ref this.m_DstState);
   this.m_Transition = this.m_SrcState.AddTransition(this.m_DstState, true);
   this.m_Transition.pushUndo = false;
   this.m_Transition.hideFlags = HideFlags.DontSave;
   this.CopyTransitionForPreview(this.m_RefTransition, ref this.m_Transition);
   this.DisableIKOnFeetIfNeeded();
   AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
   this.m_Controller.OnAnimatorControllerDirty += new System.Action(this.ControllerDirty);
 }
 private void ResampleTransition(AnimatorStateTransition transition, AvatarMask layerMask, TransitionPreview.TransitionInfo info, Animator previewObject)
 {
   this.m_IsResampling = true;
   this.m_MustResample = false;
   bool flag1 = (UnityEngine.Object) this.m_RefTransition != (UnityEngine.Object) transition;
   this.m_RefTransition = transition;
   this.m_RefTransitionInfo = info;
   this.m_LayerMask = layerMask;
   if (this.m_AvatarPreview != null)
   {
     this.m_AvatarPreview.OnDestroy();
     this.m_AvatarPreview = (AvatarPreview) null;
   }
   this.ClearController();
   Motion motion = this.m_RefSrcState.motion;
   this.Init(previewObject, !((UnityEngine.Object) motion != (UnityEngine.Object) null) ? this.m_RefDstState.motion : motion);
   if ((UnityEngine.Object) this.m_Controller == (UnityEngine.Object) null)
     return;
   this.m_AvatarPreview.Animator.allowConstantClipSamplingOptimization = false;
   this.m_StateMachine.defaultState = this.m_DstState;
   this.m_Transition.mute = true;
   AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
   this.m_AvatarPreview.Animator.Update(1E-05f);
   this.WriteParametersInController();
   this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
   float length1 = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex).length;
   this.m_StateMachine.defaultState = this.m_SrcState;
   this.m_Transition.mute = false;
   AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
   this.m_AvatarPreview.Animator.Update(1E-05f);
   this.WriteParametersInController();
   this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
   float length2 = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex).length;
   if (this.m_LayerIndex > 0)
     this.m_AvatarPreview.Animator.stabilizeFeet = false;
   float num1 = (float) ((double) length2 * (double) this.m_RefTransition.exitTime + (double) this.m_Transition.duration * (!this.m_RefTransition.hasFixedDuration ? (double) length2 : 1.0)) + length1;
   if ((double) num1 > 2000.0)
   {
     Debug.LogWarning((object) "Transition duration is longer than 2000 second, Disabling previewer.");
     this.m_ValidTransition = false;
   }
   else
   {
     float num2 = (double) this.m_RefTransition.exitTime <= 0.0 ? length2 : length2 * this.m_RefTransition.exitTime;
     float a1 = (double) num2 <= 0.0 ? 0.03333334f : Mathf.Min(Mathf.Max(num2 / 300f, 0.03333334f), num2 / 5f);
     float a2 = (double) length1 <= 0.0 ? 0.03333334f : Mathf.Min(Mathf.Max(length1 / 300f, 0.03333334f), length1 / 5f);
     float num3 = Mathf.Max(a1, num1 / 600f);
     float num4 = Mathf.Max(a2, num1 / 600f);
     float deltaTime = num3;
     float num5 = 0.0f;
     bool flag2 = false;
     bool flag3 = false;
     bool flag4 = false;
     this.m_AvatarPreview.Animator.StartRecording(-1);
     this.m_LeftStateWeightA = 0.0f;
     this.m_LeftStateTimeA = 0.0f;
     this.m_AvatarPreview.Animator.Update(0.0f);
     while (!flag4)
     {
       this.m_AvatarPreview.Animator.Update(deltaTime);
       AnimatorStateInfo animatorStateInfo = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex);
       num5 += deltaTime;
       if (!flag2)
       {
         this.m_LeftStateWeightA = this.m_LeftStateWeightB = animatorStateInfo.normalizedTime;
         this.m_LeftStateTimeA = this.m_LeftStateTimeB = num5;
         flag2 = true;
       }
       if (flag3 && (double) num5 >= (double) num1)
         flag4 = true;
       if (!flag3 && animatorStateInfo.IsName(this.m_DstState.name))
       {
         this.m_RightStateWeightA = animatorStateInfo.normalizedTime;
         this.m_RightStateTimeA = num5;
         flag3 = true;
       }
       if (!flag3)
       {
         this.m_LeftStateWeightB = animatorStateInfo.normalizedTime;
         this.m_LeftStateTimeB = num5;
       }
       if (flag3)
       {
         this.m_RightStateWeightB = animatorStateInfo.normalizedTime;
         this.m_RightStateTimeB = num5;
       }
       if (this.m_AvatarPreview.Animator.IsInTransition(this.m_LayerIndex))
         deltaTime = num4;
     }
     float num6 = num5;
     this.m_AvatarPreview.Animator.StopRecording();
     if (Mathf.Approximately(this.m_LeftStateWeightB, this.m_LeftStateWeightA) || Mathf.Approximately(this.m_RightStateWeightB, this.m_RightStateWeightA))
     {
       Debug.LogWarning((object) "Difference in effective length between states is too big. Transition preview will be disabled.");
       this.m_ValidTransition = false;
     }
     else
     {
       float num7 = (float) (((double) this.m_LeftStateTimeB - (double) this.m_LeftStateTimeA) / ((double) this.m_LeftStateWeightB - (double) this.m_LeftStateWeightA));
       float num8 = (float) (((double) this.m_RightStateTimeB - (double) this.m_RightStateTimeA) / ((double) this.m_RightStateWeightB - (double) this.m_RightStateWeightA));
       if (this.m_MustSampleMotions)
       {
         this.m_MustSampleMotions = false;
         this.m_SrcPivotList.Clear();
         this.m_DstPivotList.Clear();
         float num9 = num4;
         this.m_StateMachine.defaultState = this.m_DstState;
         this.m_Transition.mute = true;
         AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
         this.m_AvatarPreview.Animator.Update(0.0f);
         this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
         this.m_AvatarPreview.Animator.Update(1E-07f);
         this.WriteParametersInController();
         float num10 = 0.0f;
         while ((double) num10 <= (double) num8)
         {
           this.m_DstPivotList.Add(new Timeline.PivotSample()
           {
             m_Time = num10,
             m_Weight = this.m_AvatarPreview.Animator.pivotWeight
           });
           this.m_AvatarPreview.Animator.Update(num9 * 2f);
           num10 += num9 * 2f;
         }
         float num11 = num3;
         this.m_StateMachine.defaultState = this.m_SrcState;
         this.m_Transition.mute = true;
         AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
         this.m_AvatarPreview.Animator.Update(1E-07f);
         this.WriteParametersInController();
         this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
         float num12 = 0.0f;
         while ((double) num12 <= (double) num7)
         {
           this.m_SrcPivotList.Add(new Timeline.PivotSample()
           {
             m_Time = num12,
             m_Weight = this.m_AvatarPreview.Animator.pivotWeight
           });
           this.m_AvatarPreview.Animator.Update(num11 * 2f);
           num12 += num11 * 2f;
         }
         this.m_Transition.mute = false;
         AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
         this.m_AvatarPreview.Animator.Update(1E-07f);
         this.WriteParametersInController();
       }
       this.m_Timeline.StopTime = this.m_AvatarPreview.timeControl.stopTime = num6;
       this.m_AvatarPreview.timeControl.currentTime = this.m_Timeline.Time;
       if (flag1)
       {
         Timeline timeline = this.m_Timeline;
         float num9 = this.m_AvatarPreview.timeControl.currentTime = this.m_AvatarPreview.timeControl.startTime = 0.0f;
         this.m_Timeline.StartTime = num9;
         double num10 = (double) num9;
         timeline.Time = (float) num10;
         this.m_Timeline.ResetRange();
       }
       this.m_AvatarPreview.Animator.StartPlayback();
       this.m_IsResampling = false;
     }
   }
 }
 private void ClearController()
 {
   if (this.m_AvatarPreview != null && (UnityEngine.Object) this.m_AvatarPreview.Animator != (UnityEngine.Object) null)
     AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, (AnimatorController) null);
   UnityEngine.Object.DestroyImmediate((UnityEngine.Object) this.m_Controller);
   UnityEngine.Object.DestroyImmediate((UnityEngine.Object) this.m_SrcState);
   UnityEngine.Object.DestroyImmediate((UnityEngine.Object) this.m_DstState);
   UnityEngine.Object.DestroyImmediate((UnityEngine.Object) this.m_Transition);
   this.m_StateMachine = (AnimatorStateMachine) null;
   this.m_Controller = (AnimatorController) null;
   this.m_SrcState = (AnimatorState) null;
   this.m_DstState = (AnimatorState) null;
   this.m_Transition = (AnimatorStateTransition) null;
 }