Ejemplo n.º 1
0
        public static GameObject FindBestFittingRenderableGameObjectFromModelAsset(UnityEngine.Object asset, ModelImporterAnimationType animationType)
        {
            GameObject result;

            if (asset == null)
            {
                result = null;
            }
            else
            {
                ModelImporter modelImporter = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(asset)) as ModelImporter;
                if (modelImporter == null)
                {
                    result = null;
                }
                else
                {
                    string     assetPath  = modelImporter.CalculateBestFittingPreviewGameObject();
                    GameObject gameObject = AssetDatabase.LoadMainAssetAtPath(assetPath) as GameObject;
                    if (AvatarPreview.IsValidPreviewGameObject(gameObject, ModelImporterAnimationType.None))
                    {
                        result = gameObject;
                    }
                    else
                    {
                        result = null;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static ModelImporterAnimationType GetAnimationType(Motion motion)
        {
            AnimationClip firstAnimationClipFromMotion = AvatarPreview.GetFirstAnimationClipFromMotion(motion);
            ModelImporterAnimationType result;

            if (firstAnimationClipFromMotion)
            {
                if (firstAnimationClipFromMotion.legacy)
                {
                    result = ModelImporterAnimationType.Legacy;
                }
                else if (firstAnimationClipFromMotion.humanMotion)
                {
                    result = ModelImporterAnimationType.Human;
                }
                else
                {
                    result = ModelImporterAnimationType.Generic;
                }
            }
            else
            {
                result = ModelImporterAnimationType.None;
            }
            return(result);
        }
Ejemplo n.º 3
0
        public void ResetPreviewInstance()
        {
            UnityEngine.Object.DestroyImmediate(this.m_PreviewInstance);
            GameObject go = AvatarPreview.CalculatePreviewGameObject(this.m_SourceScenePreviewAnimator, this.m_SourcePreviewMotion, this.animationClipType);

            this.SetupBounds(go);
        }
Ejemplo n.º 4
0
        private static GameObject CalculatePreviewGameObject(Animator selectedAnimator, Motion motion, ModelImporterAnimationType animationType)
        {
            AnimationClip firstAnimationClipFromMotion = AvatarPreview.GetFirstAnimationClipFromMotion(motion);
            GameObject    gameObject = AvatarPreviewSelection.GetPreview(animationType);

            if (AvatarPreview.IsValidPreviewGameObject(gameObject, ModelImporterAnimationType.None))
            {
                return(gameObject);
            }
            if (selectedAnimator != null && AvatarPreview.IsValidPreviewGameObject(selectedAnimator.gameObject, animationType))
            {
                return(selectedAnimator.gameObject);
            }
            gameObject = AvatarPreview.FindBestFittingRenderableGameObjectFromModelAsset(firstAnimationClipFromMotion, animationType);
            if (gameObject != null)
            {
                return(gameObject);
            }
            if (animationType == ModelImporterAnimationType.Human)
            {
                return(AvatarPreview.GetHumanoidFallback());
            }
            if (animationType == ModelImporterAnimationType.Generic)
            {
                return(AvatarPreview.GetGenericAnimationFallback());
            }
            return(null);
        }
Ejemplo n.º 5
0
            public static void Start(AvatarPreview owner)
            {
                var operation = ScriptableObject.CreateInstance <ObjectSelectorOperation>();

                operation.m_Owner    = owner;
                operation.m_Selector = ObjectSelector.get;
                operation.Execute();
            }
Ejemplo n.º 6
0
 public void OnDestroy()
 {
     this.ClearStateMachine();
     if (this.m_AvatarPreview != null)
     {
         this.m_AvatarPreview.OnDestroy();
         this.m_AvatarPreview = null;
     }
 }
Ejemplo n.º 7
0
 public void OnDestroy()
 {
     this.ClearStateMachine();
     if (this.m_AvatarPreview == null)
     {
         return;
     }
     this.m_AvatarPreview.OnDestroy();
     this.m_AvatarPreview = (AvatarPreview)null;
 }
 public void Init(BlendTree blendTree, Animator animator)
 {
   this.m_BlendTree = blendTree;
   if (this.m_AvatarPreview == null)
   {
     this.m_AvatarPreview = new AvatarPreview(animator, (Motion) this.m_BlendTree);
     this.m_AvatarPreview.OnAvatarChangeFunc = new AvatarPreview.OnAvatarChange(this.OnPreviewAvatarChanged);
     this.m_PrevIKOnFeet = this.m_AvatarPreview.IKOnFeet;
   }
   this.CreateStateMachine();
 }
Ejemplo n.º 9
0
 public void Init(BlendTree blendTree, Animator animator)
 {
     this.m_BlendTree = blendTree;
     if (this.m_AvatarPreview == null)
     {
         this.m_AvatarPreview = new AvatarPreview(animator, this.m_BlendTree);
         this.m_AvatarPreview.OnAvatarChangeFunc = new AvatarPreview.OnAvatarChange(this.OnPreviewAvatarChanged);
         this.m_PrevIKOnFeet = this.m_AvatarPreview.IKOnFeet;
     }
     this.CreateStateMachine();
 }
Ejemplo n.º 10
0
 private void SetPreviewCharacterEnabled(bool enabled, bool showReference)
 {
     if (this.m_PreviewInstance != null)
     {
         AvatarPreview.SetEnabledRecursive(this.m_PreviewInstance, enabled);
     }
     AvatarPreview.SetEnabledRecursive(this.m_ReferenceInstance, showReference && enabled);
     AvatarPreview.SetEnabledRecursive(this.m_DirectionInstance, showReference && enabled);
     AvatarPreview.SetEnabledRecursive(this.m_PivotInstance, showReference && enabled);
     AvatarPreview.SetEnabledRecursive(this.m_RootInstance, showReference && enabled);
 }
Ejemplo n.º 11
0
 public static bool IsValidPreviewGameObject(GameObject target, ModelImporterAnimationType requiredClipType)
 {
     if ((Object)target != (Object)null && !target.activeSelf)
     {
         Debug.LogWarning((object)"Can't preview inactive object, using fallback object");
     }
     if ((Object)target != (Object)null && target.activeSelf && GameObjectInspector.HasRenderablePartsRecurse(target))
     {
         return((requiredClipType == ModelImporterAnimationType.None ? 0 : (AvatarPreview.GetAnimationType(target) != requiredClipType ? 1 : 0)) == 0);
     }
     return(false);
 }
Ejemplo n.º 12
0
 public void OnDestroy()
 {
     this.ClearController();
     if (this.m_Timeline != null)
     {
         this.m_Timeline = null;
     }
     if (this.m_AvatarPreview != null)
     {
         this.m_AvatarPreview.OnDestroy();
         this.m_AvatarPreview = null;
     }
 }
Ejemplo n.º 13
0
 public void OnDestroy()
 {
     this.ClearController();
     if (this.m_Timeline != null)
     {
         this.m_Timeline = (Timeline)null;
     }
     if (this.m_AvatarPreview == null)
     {
         return;
     }
     this.m_AvatarPreview.OnDestroy();
     this.m_AvatarPreview = (AvatarPreview)null;
 }
Ejemplo n.º 14
0
        public static ModelImporterAnimationType GetAnimationType(Motion motion)
        {
            AnimationClip animationClipFromMotion = AvatarPreview.GetFirstAnimationClipFromMotion(motion);

            if (!(bool)((Object)animationClipFromMotion))
            {
                return(ModelImporterAnimationType.None);
            }
            if (animationClipFromMotion.legacy)
            {
                return(ModelImporterAnimationType.Legacy);
            }
            return(animationClipFromMotion.humanMotion ? ModelImporterAnimationType.Human : ModelImporterAnimationType.Generic);
        }
        public void OnDisable()
        {
            ClearController();

            if (m_Timeline != null)
            {
                m_Timeline = null;
            }

            if (m_AvatarPreview != null)
            {
                m_AvatarPreview.OnDisable();
                m_AvatarPreview = null;
            }
        }
Ejemplo n.º 16
0
 private void InitInstance(Animator scenePreviewObject, Motion motion)
 {
     this.m_SourcePreviewMotion        = motion;
     this.m_SourceScenePreviewAnimator = scenePreviewObject;
     if (this.m_PreviewInstance == null)
     {
         GameObject go = AvatarPreview.CalculatePreviewGameObject(scenePreviewObject, motion, this.animationClipType);
         this.SetupBounds(go);
     }
     if (this.timeControl == null)
     {
         this.timeControl = new TimeControl();
     }
     if (this.m_ReferenceInstance == null)
     {
         GameObject original = (GameObject)EditorGUIUtility.Load("Avatar/dial_flat.prefab");
         this.m_ReferenceInstance = UnityEngine.Object.Instantiate <GameObject>(original, Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_ReferenceInstance);
         this.previewUtility.AddSingleGO(this.m_ReferenceInstance);
     }
     if (this.m_DirectionInstance == null)
     {
         GameObject original2 = (GameObject)EditorGUIUtility.Load("Avatar/arrow.fbx");
         this.m_DirectionInstance = UnityEngine.Object.Instantiate <GameObject>(original2, Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_DirectionInstance);
         this.previewUtility.AddSingleGO(this.m_DirectionInstance);
     }
     if (this.m_PivotInstance == null)
     {
         GameObject original3 = (GameObject)EditorGUIUtility.Load("Avatar/root.fbx");
         this.m_PivotInstance = UnityEngine.Object.Instantiate <GameObject>(original3, Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_PivotInstance);
         this.previewUtility.AddSingleGO(this.m_PivotInstance);
     }
     if (this.m_RootInstance == null)
     {
         GameObject original4 = (GameObject)EditorGUIUtility.Load("Avatar/root.fbx");
         this.m_RootInstance = UnityEngine.Object.Instantiate <GameObject>(original4, Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_RootInstance);
         this.previewUtility.AddSingleGO(this.m_RootInstance);
     }
     this.m_IKOnFeet                = EditorPrefs.GetBool("AvatarpreviewShowIK", false);
     this.m_ShowReference           = EditorPrefs.GetBool("AvatarpreviewShowReference", true);
     this.is2D                      = EditorPrefs.GetBool("Avatarpreview2D", EditorSettings.defaultBehaviorMode == EditorBehaviorMode.Mode2D);
     this.timeControl.playbackSpeed = EditorPrefs.GetFloat("AvatarpreviewSpeed", 1f);
     this.SetPreviewCharacterEnabled(false, false);
     this.m_PivotPositionOffset = Vector3.zero;
 }
Ejemplo n.º 17
0
 private void SetPreviewAvatarOption(object obj)
 {
     this.m_Option = (AvatarPreview.PreviewPopupOptions)obj;
     if (this.m_Option == AvatarPreview.PreviewPopupOptions.Auto)
     {
         this.SetPreview(null);
     }
     else if (this.m_Option == AvatarPreview.PreviewPopupOptions.DefaultModel)
     {
         this.SetPreview(AvatarPreview.GetHumanoidFallback());
     }
     else if (this.m_Option == AvatarPreview.PreviewPopupOptions.Other)
     {
         ObjectSelector.get.Show(null, typeof(GameObject), null, false);
         ObjectSelector.get.objectSelectorID = this.m_ModelSelectorId;
     }
 }
Ejemplo n.º 18
0
        private void SetPreviewAvatarOption(object obj)
        {
            switch ((AvatarPreview.PreviewPopupOptions)obj)
            {
            case AvatarPreview.PreviewPopupOptions.Auto:
                this.SetPreview((GameObject)null);
                break;

            case AvatarPreview.PreviewPopupOptions.DefaultModel:
                this.SetPreview(AvatarPreview.GetHumanoidFallback());
                break;

            case AvatarPreview.PreviewPopupOptions.Other:
                ObjectSelector.get.Show((Object)null, typeof(GameObject), (SerializedProperty)null, false);
                ObjectSelector.get.objectSelectorID = this.m_ModelSelectorId;
                break;
            }
        }
Ejemplo n.º 19
0
        public static ModelImporterAnimationType GetAnimationType(Motion motion)
        {
            AnimationClip firstAnimationClipFromMotion = AvatarPreview.GetFirstAnimationClipFromMotion(motion);

            if (!firstAnimationClipFromMotion)
            {
                return(ModelImporterAnimationType.None);
            }
            if (firstAnimationClipFromMotion.legacy)
            {
                return(ModelImporterAnimationType.Legacy);
            }
            if (firstAnimationClipFromMotion.humanMotion)
            {
                return(ModelImporterAnimationType.Human);
            }
            return(ModelImporterAnimationType.Generic);
        }
Ejemplo n.º 20
0
 private void SetupBounds(GameObject go)
 {
     this.m_IsValid = (go != null && go != AvatarPreview.GetGenericAnimationFallback());
     if (go != null)
     {
         this.m_PreviewInstance = EditorUtility.InstantiateForAnimatorPreview(go);
         Bounds bounds = new Bounds(this.m_PreviewInstance.transform.position, Vector3.zero);
         GameObjectInspector.GetRenderableBoundsRecurse(ref bounds, this.m_PreviewInstance);
         this.m_BoundingVolumeScale = Mathf.Max(bounds.size.x, Mathf.Max(bounds.size.y, bounds.size.z));
         if (this.Animator && this.Animator.isHuman)
         {
             this.m_AvatarScale = (this.m_ZoomFactor = this.Animator.humanScale);
         }
         else
         {
             this.m_AvatarScale = (this.m_ZoomFactor = this.m_BoundingVolumeScale / 2f);
         }
     }
 }
Ejemplo n.º 21
0
 private void Init(Animator scenePreviewObject, Motion motion)
 {
     if (this.m_AvatarPreview == null)
     {
         this.m_AvatarPreview = new AvatarPreview(scenePreviewObject, motion);
         this.m_AvatarPreview.OnAvatarChangeFunc = new AvatarPreview.OnAvatarChange(this.OnPreviewAvatarChanged);
         this.m_AvatarPreview.ShowIKOnFeetButton = false;
     }
     if (this.m_Timeline == null)
     {
         this.m_Timeline          = new Timeline();
         this.m_MustSampleMotions = true;
     }
     this.CreateController();
     if (this.m_ParameterInfoList == null)
     {
         this.CreateParameterInfoList();
     }
 }
Ejemplo n.º 22
0
        private void Init(Animator scenePreviewObject, Motion motion)
        {
            if (m_AvatarPreview == null)
            {
                m_AvatarPreview = new AvatarPreview(scenePreviewObject, motion);
                m_AvatarPreview.OnAvatarChangeFunc = OnPreviewAvatarChanged;
                m_AvatarPreview.ShowIKOnFeetButton = false;
                m_AvatarPreview.ResetPreviewFocus();
            }

            if (m_Timeline == null)
            {
                m_Timeline          = new TimelineControl();
                m_MustSampleMotions = true;
            }

            CreateController();

            CreateParameterInfoList();
        }
Ejemplo n.º 23
0
        public static GameObject FindBestFittingRenderableGameObjectFromModelAsset(Object asset, ModelImporterAnimationType animationType)
        {
            if (asset == (Object)null)
            {
                return((GameObject)null);
            }
            ModelImporter atPath = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(asset)) as ModelImporter;

            if ((Object)atPath == (Object)null)
            {
                return((GameObject)null);
            }
            GameObject target = AssetDatabase.LoadMainAssetAtPath(atPath.CalculateBestFittingPreviewGameObject()) as GameObject;

            if (AvatarPreview.IsValidPreviewGameObject(target, animationType))
            {
                return(target);
            }
            return((GameObject)null);
        }
Ejemplo n.º 24
0
 private void InitInstance(Animator scenePreviewObject, Motion motion)
 {
     this.m_SourcePreviewMotion        = motion;
     this.m_SourceScenePreviewAnimator = scenePreviewObject;
     if ((Object)this.m_PreviewInstance == (Object)null)
     {
         this.SetupBounds(AvatarPreview.CalculatePreviewGameObject(scenePreviewObject, motion, this.animationClipType));
     }
     if (this.timeControl == null)
     {
         this.timeControl = new TimeControl();
     }
     if ((Object)this.m_ReferenceInstance == (Object)null)
     {
         this.m_ReferenceInstance = (GameObject)Object.Instantiate(EditorGUIUtility.Load("Avatar/dial_flat.prefab"), Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_ReferenceInstance);
     }
     if ((Object)this.m_DirectionInstance == (Object)null)
     {
         this.m_DirectionInstance = (GameObject)Object.Instantiate(EditorGUIUtility.Load("Avatar/arrow.fbx"), Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_DirectionInstance);
     }
     if ((Object)this.m_PivotInstance == (Object)null)
     {
         this.m_PivotInstance = (GameObject)Object.Instantiate(EditorGUIUtility.Load("Avatar/root.fbx"), Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_PivotInstance);
     }
     if ((Object)this.m_RootInstance == (Object)null)
     {
         this.m_RootInstance = (GameObject)Object.Instantiate(EditorGUIUtility.Load("Avatar/root.fbx"), Vector3.zero, Quaternion.identity);
         EditorUtility.InitInstantiatedPreviewRecursive(this.m_RootInstance);
     }
     this.m_IKOnFeet                = EditorPrefs.GetBool("AvatarpreviewShowIK", false);
     this.m_ShowReference           = EditorPrefs.GetBool("AvatarpreviewShowReference", true);
     this.timeControl.playbackSpeed = EditorPrefs.GetFloat("AvatarpreviewSpeed", 1f);
     this.SetPreviewCharacterEnabled(false, false);
 }
 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;
     }
   }
 }
 public void OnDestroy()
 {
   this.ClearController();
   if (this.m_Timeline != null)
     this.m_Timeline = (Timeline) null;
   if (this.m_AvatarPreview == null)
     return;
   this.m_AvatarPreview.OnDestroy();
   this.m_AvatarPreview = (AvatarPreview) null;
 }
Ejemplo n.º 27
0
 public static bool IsValidPreviewGameObject(GameObject target, ModelImporterAnimationType requiredClipType)
 {
     if (target != null && !target.activeSelf)
     {
         Debug.LogWarning("Can't preview inactive object, using fallback object");
     }
     return(target != null && target.activeSelf && GameObjectInspector.HasRenderableParts(target) && (requiredClipType == ModelImporterAnimationType.None || AvatarPreview.GetAnimationType(target) == requiredClipType));
 }
Ejemplo n.º 28
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.º 29
0
 public void OnDestroy()
 {
     this.ClearStateMachine();
     if (this.m_AvatarPreview != null)
     {
         this.m_AvatarPreview.OnDestroy();
         this.m_AvatarPreview = null;
     }
 }
Ejemplo n.º 30
0
 private void Init(Animator scenePreviewObject, Motion motion)
 {
     if (this.m_AvatarPreview == null)
     {
         this.m_AvatarPreview = new AvatarPreview(scenePreviewObject, motion);
         this.m_AvatarPreview.OnAvatarChangeFunc = new AvatarPreview.OnAvatarChange(this.OnPreviewAvatarChanged);
         this.m_AvatarPreview.ShowIKOnFeetButton = false;
     }
     if (this.m_Timeline == null)
     {
         this.m_Timeline = new Timeline();
         this.m_MustSampleMotions = true;
     }
     this.CreateController();
     if (this.m_ParameterInfoList == null)
     {
         this.CreateParameterInfoList();
     }
 }
Ejemplo n.º 31
0
        private void ResampleTransition(AnimatorStateTransition transition, AvatarMask layerMask, TransitionPreview.TransitionInfo info, Animator previewObject)
        {
            this.m_IsResampling    = true;
            this.m_MustResample    = false;
            this.m_ValidTransition = true;
            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_IsResampling = false;
            }
            else
            {
                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 + this.m_Transition.duration * ((!this.m_RefTransition.hasFixedDuration) ? length2 : 1f) + length;
                if (num > 2000f)
                {
                    Debug.LogWarning("Transition duration is longer than 2000 second, Disabling previewer.");
                    this.m_ValidTransition = false;
                    this.m_IsResampling    = false;
                }
                else
                {
                    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 / 600f);
                    num4 = Mathf.Max(num4, num / 600f);
                    float num5  = num3;
                    float num6  = 0f;
                    bool  flag2 = false;
                    bool  flag3 = false;
                    bool  flag4 = false;
                    if (this.m_RefTransition.exitTime == 0f)
                    {
                        this.m_AvatarPreview.Animator.CrossFade(0, 0f, 0, 0.9999f);
                    }
                    this.m_AvatarPreview.Animator.StartRecording(-1);
                    this.m_LeftStateWeightA = 0f;
                    this.m_LeftStateTimeA   = 0f;
                    this.m_AvatarPreview.Animator.Update(0f);
                    while (!flag4 && num6 < num)
                    {
                        this.m_AvatarPreview.Animator.Update(num5);
                        AnimatorStateInfo currentAnimatorStateInfo = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex);
                        num6 += num5;
                        if (!flag2)
                        {
                            this.m_LeftStateWeightA = (this.m_LeftStateWeightB = currentAnimatorStateInfo.normalizedTime);
                            this.m_LeftStateTimeA   = (this.m_LeftStateTimeB = 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("Difference in effective length between states is too big. Transition preview will be disabled.");
                        this.m_ValidTransition = false;
                        this.m_IsResampling    = false;
                    }
                    else
                    {
                        float num7 = (this.m_LeftStateTimeB - this.m_LeftStateTimeA) / (this.m_LeftStateWeightB - this.m_LeftStateWeightA);
                        float num8 = (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.Update(0f);
                            this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
                            this.m_AvatarPreview.Animator.Update(1E-07f);
                            this.WriteParametersInController();
                            for (num6 = 0f; num6 <= num8; num6 += num5 * 2f)
                            {
                                TimelineControl.PivotSample pivotSample = new TimelineControl.PivotSample();
                                pivotSample.m_Time   = num6;
                                pivotSample.m_Weight = this.m_AvatarPreview.Animator.pivotWeight;
                                this.m_DstPivotList.Add(pivotSample);
                                this.m_AvatarPreview.Animator.Update(num5 * 2f);
                            }
                            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);
                            for (num6 = 0f; num6 <= num7; num6 += num5 * 2f)
                            {
                                TimelineControl.PivotSample pivotSample2 = new TimelineControl.PivotSample();
                                pivotSample2.m_Time   = num6;
                                pivotSample2.m_Weight = this.m_AvatarPreview.Animator.pivotWeight;
                                this.m_SrcPivotList.Add(pivotSample2);
                                this.m_AvatarPreview.Animator.Update(num5 * 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 = stopTime);
                        this.m_AvatarPreview.timeControl.currentTime = this.m_Timeline.Time;
                        if (flag)
                        {
                            TimelineControl arg_80E_0 = this.m_Timeline;
                            float           num9      = this.m_AvatarPreview.timeControl.currentTime = (this.m_AvatarPreview.timeControl.startTime = 0f);
                            this.m_Timeline.StartTime = num9;
                            arg_80E_0.Time            = num9;
                            this.m_Timeline.ResetRange();
                        }
                        this.m_AvatarPreview.Animator.StartPlayback();
                        this.m_IsResampling = false;
                    }
                }
            }
        }
Ejemplo n.º 32
0
 public void OnDestroy()
 {
     this.ClearController();
     if (this.m_Timeline != null)
     {
         this.m_Timeline = null;
     }
     if (this.m_AvatarPreview != null)
     {
         this.m_AvatarPreview.OnDestroy();
         this.m_AvatarPreview = null;
     }
 }
		private void Init()
		{
			if (AnimationClipEditor.styles == null)
			{
				AnimationClipEditor.styles = new AnimationClipEditor.Styles();
			}
			if (this.m_AvatarPreview == null)
			{
				this.m_AvatarPreview = new AvatarPreview(null, this.target as Motion);
				this.m_AvatarPreview.OnAvatarChangeFunc = new AvatarPreview.OnAvatarChange(this.SetPreviewAvatar);
				this.m_AvatarPreview.fps = Mathf.RoundToInt((this.target as AnimationClip).frameRate);
				this.m_AvatarPreview.ShowIKOnFeetButton = (this.target as Motion).isHumanMotion;
			}
		}
Ejemplo n.º 34
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.º 35
0
 public ObjectSelectorOperation(AvatarPreview owner, ObjectSelector selector)
 {
     m_Owner    = owner;
     m_Selector = selector;
 }
Ejemplo n.º 36
0
        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;
                }
            }
        }
Ejemplo n.º 37
0
            public static void Start(AvatarPreview owner)
            {
                var operation = new ObjectSelectorOperation(owner, ObjectSelector.get);

                operation.Execute();
            }
Ejemplo n.º 38
0
        public Texture DoRenderPreview(Rect previewRect, GUIStyle background)
        {
            this.m_PreviewUtility.BeginPreview(previewRect, background);
            Vector3    bodyPosition = this.bodyPosition;
            Quaternion quaternion;
            Vector3    vector;
            Quaternion quaternion2;
            Vector3    pivotPos;

            if (this.Animator && this.Animator.isHuman)
            {
                quaternion  = this.Animator.rootRotation;
                vector      = this.Animator.rootPosition;
                quaternion2 = this.Animator.bodyRotation;
                pivotPos    = this.Animator.pivotPosition;
            }
            else
            {
                if (this.Animator && this.Animator.hasRootMotion)
                {
                    quaternion  = this.Animator.rootRotation;
                    vector      = this.Animator.rootPosition;
                    quaternion2 = Quaternion.identity;
                    pivotPos    = Vector3.zero;
                }
                else
                {
                    quaternion  = Quaternion.identity;
                    vector      = Vector3.zero;
                    quaternion2 = Quaternion.identity;
                    pivotPos    = Vector3.zero;
                }
            }
            bool    oldFog  = this.SetupPreviewLightingAndFx();
            Vector3 forward = quaternion2 * Vector3.forward;

            forward[1] = 0f;
            Quaternion directionRot = Quaternion.LookRotation(forward);
            Vector3    directionPos = vector;
            Quaternion pivotRot     = quaternion;

            this.PositionPreviewObjects(pivotRot, pivotPos, quaternion2, bodyPosition, directionRot, quaternion, vector, directionPos, this.m_AvatarScale);
            bool  flag = Mathf.Abs(this.m_NextFloorHeight - this.m_PrevFloorHeight) > this.m_ZoomFactor * 0.01f;
            float num2;
            float num3;

            if (flag)
            {
                float num = (this.m_NextFloorHeight >= this.m_PrevFloorHeight) ? 0.8f : 0.2f;
                num2 = ((this.timeControl.normalizedTime >= num) ? this.m_NextFloorHeight : this.m_PrevFloorHeight);
                num3 = Mathf.Clamp01(Mathf.Abs(this.timeControl.normalizedTime - num) / 0.2f);
            }
            else
            {
                num2 = this.m_PrevFloorHeight;
                num3 = 1f;
            }
            Quaternion identity = Quaternion.identity;
            Vector3    position = new Vector3(0f, 0f, 0f);

            position   = this.m_ReferenceInstance.transform.position;
            position.y = num2;
            Matrix4x4     matrix;
            RenderTexture renderTexture = this.RenderPreviewShadowmap(this.m_PreviewUtility.m_Light[0], this.m_BoundingVolumeScale / 2f, bodyPosition, position, out matrix);

            this.m_PreviewUtility.m_Camera.nearClipPlane = 0.5f * this.m_ZoomFactor;
            this.m_PreviewUtility.m_Camera.farClipPlane  = 100f * this.m_AvatarScale;
            Quaternion rotation  = Quaternion.Euler(-this.m_PreviewDir.y, -this.m_PreviewDir.x, 0f);
            Vector3    position2 = rotation * (Vector3.forward * -5.5f * this.m_ZoomFactor) + bodyPosition + this.m_PivotPositionOffset;

            this.m_PreviewUtility.m_Camera.transform.position = position2;
            this.m_PreviewUtility.m_Camera.transform.rotation = rotation;
            position.y = num2;
            Material  floorMaterial = this.m_FloorMaterial;
            Matrix4x4 matrix2       = Matrix4x4.TRS(position, identity, Vector3.one * 5f * this.m_AvatarScale);

            floorMaterial.mainTextureOffset = -new Vector2(position.x, position.z) * 5f * 0.08f * (1f / this.m_AvatarScale);
            floorMaterial.SetTexture("_ShadowTexture", renderTexture);
            floorMaterial.SetMatrix("_ShadowTextureMatrix", matrix);
            floorMaterial.SetVector("_Alphas", new Vector4(0.5f * num3, 0.3f * num3, 0f, 0f));
            Graphics.DrawMesh(this.m_FloorPlane, matrix2, floorMaterial, Camera.PreviewCullingLayer, this.m_PreviewUtility.m_Camera, 0);
            if (flag)
            {
                bool  flag2 = this.m_NextFloorHeight > this.m_PrevFloorHeight;
                float num4  = (!flag2) ? this.m_PrevFloorHeight : this.m_NextFloorHeight;
                float from  = (!flag2) ? this.m_NextFloorHeight : this.m_PrevFloorHeight;
                float num5  = ((num4 != num2) ? 1f : (1f - num3)) * Mathf.InverseLerp(from, num4, vector.y);
                position.y = num4;
                Material floorMaterialSmall = this.m_FloorMaterialSmall;
                floorMaterialSmall.mainTextureOffset = -new Vector2(position.x, position.z) * 0.2f * 0.08f;
                floorMaterialSmall.SetTexture("_ShadowTexture", renderTexture);
                floorMaterialSmall.SetMatrix("_ShadowTextureMatrix", matrix);
                floorMaterialSmall.SetVector("_Alphas", new Vector4(0.5f * num5, 0f, 0f, 0f));
                Matrix4x4 matrix3 = Matrix4x4.TRS(position, identity, Vector3.one * 0.2f * this.m_AvatarScale);
                Graphics.DrawMesh(this.m_FloorPlane, matrix3, floorMaterialSmall, Camera.PreviewCullingLayer, this.m_PreviewUtility.m_Camera, 0);
            }
            this.SetPreviewCharacterEnabled(true, this.m_ShowReference);
            this.m_PreviewUtility.m_Camera.Render();
            this.SetPreviewCharacterEnabled(false, false);
            AvatarPreview.TeardownPreviewLightingAndFx(oldFog);
            RenderTexture.ReleaseTemporary(renderTexture);
            return(this.m_PreviewUtility.EndPreview());
        }
Ejemplo n.º 39
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;
		}
 public void OnDestroy()
 {
   this.ClearStateMachine();
   if (this.m_AvatarPreview == null)
     return;
   this.m_AvatarPreview.OnDestroy();
   this.m_AvatarPreview = (AvatarPreview) null;
 }