UnityEditor.AnimationClipEditor.MuscleClipGUI C# (CSharp) Method

MuscleClipGUI() private method

private MuscleClipGUI ( ) : void
return void
        private void MuscleClipGUI()
        {
            bool changed;
            EditorGUI.BeginChangeCheck();
            this.InitController();
            AnimationClipSettings animationClipSettings = AnimationUtility.GetAnimationClipSettings(this.m_Clip);
            bool isHumanMotion = (this.target as Motion).isHumanMotion;
            bool flag2 = AnimationUtility.HasMotionCurves(this.m_Clip);
            bool flag3 = AnimationUtility.HasRootCurves(this.m_Clip);
            bool flag4 = AnimationUtility.HasGenericRootTransform(this.m_Clip);
            bool flag5 = AnimationUtility.HasMotionFloatCurves(this.m_Clip);
            this.m_StartFrame = !this.m_DraggingRange ? (animationClipSettings.startTime * this.m_Clip.frameRate) : this.m_StartFrame;
            this.m_StopFrame = !this.m_DraggingRange ? (animationClipSettings.stopTime * this.m_Clip.frameRate) : this.m_StopFrame;
            bool changedStart = false;
            bool changedStop = false;
            if (this.m_ClipInfo != null)
            {
                if (isHumanMotion)
                {
                    if (this.m_DirtyQualityCurves)
                    {
                        this.CalculateQualityCurves();
                    }
                    if ((this.m_QualityCurves[0] == null) && (Event.current.type == EventType.Repaint))
                    {
                        this.m_DirtyQualityCurves = true;
                        base.Repaint();
                    }
                }
                this.ClipRangeGUI(ref this.m_StartFrame, ref this.m_StopFrame, out changedStart, out changedStop);
            }
            float startTime = this.m_StartFrame / this.m_Clip.frameRate;
            float stopTime = this.m_StopFrame / this.m_Clip.frameRate;
            if (!this.m_DraggingRange)
            {
                animationClipSettings.startTime = startTime;
                animationClipSettings.stopTime = stopTime;
            }
            this.m_AvatarPreview.timeControl.startTime = startTime;
            this.m_AvatarPreview.timeControl.stopTime = stopTime;
            if (changedStart)
            {
                this.m_AvatarPreview.timeControl.nextCurrentTime = startTime;
            }
            if (changedStop)
            {
                this.m_AvatarPreview.timeControl.nextCurrentTime = stopTime;
            }
            EditorGUIUtility.labelWidth = 0f;
            EditorGUIUtility.fieldWidth = 0f;
            MuscleClipQualityInfo info = MuscleClipEditorUtilities.GetMuscleClipQualityInfo(this.m_Clip, startTime, stopTime);
            Rect controlRect = EditorGUILayout.GetControlRect(new GUILayoutOption[0]);
            this.LoopToggle(controlRect, styles.LoopTime, ref animationClipSettings.loopTime);
            EditorGUI.BeginDisabledGroup(!animationClipSettings.loopTime);
            EditorGUI.indentLevel++;
            Rect r = EditorGUILayout.GetControlRect(new GUILayoutOption[0]);
            this.LoopToggle(r, styles.LoopPose, ref animationClipSettings.loopBlend);
            animationClipSettings.cycleOffset = EditorGUILayout.FloatField(styles.LoopCycleOffset, animationClipSettings.cycleOffset, new GUILayoutOption[0]);
            EditorGUI.indentLevel--;
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.Space();
            bool flag8 = isHumanMotion && (changedStart || changedStop);
            if (!flag3 || flag2)
            {
                goto Label_0689;
            }
            GUILayout.Label("Root Transform Rotation", EditorStyles.label, new GUILayoutOption[0]);
            EditorGUI.indentLevel++;
            Rect rect3 = EditorGUILayout.GetControlRect(new GUILayoutOption[0]);
            this.LoopToggle(rect3, styles.BakeIntoPoseOrientation, ref animationClipSettings.loopBlendOrientation);
            int selectedIndex = !animationClipSettings.keepOriginalOrientation ? 1 : 0;
            selectedIndex = EditorGUILayout.Popup(!animationClipSettings.loopBlendOrientation ? styles.BasedUponStartOrientation : styles.BasedUponOrientation, selectedIndex, !isHumanMotion ? styles.BasedUponRotationOpt : styles.BasedUponRotationHumanOpt, new GUILayoutOption[0]);
            animationClipSettings.keepOriginalOrientation = selectedIndex == 0;
            if (flag8)
            {
                EditorGUILayout.GetControlRect(new GUILayoutOption[0]);
            }
            else
            {
                animationClipSettings.orientationOffsetY = EditorGUILayout.FloatField(styles.OrientationOffsetY, animationClipSettings.orientationOffsetY, new GUILayoutOption[0]);
            }
            EditorGUI.indentLevel--;
            EditorGUILayout.Space();
            GUILayout.Label("Root Transform Position (Y)", EditorStyles.label, new GUILayoutOption[0]);
            EditorGUI.indentLevel++;
            Rect rect4 = EditorGUILayout.GetControlRect(new GUILayoutOption[0]);
            this.LoopToggle(rect4, styles.BakeIntoPosePositionY, ref animationClipSettings.loopBlendPositionY);
            if (isHumanMotion)
            {
                int num4;
                if (animationClipSettings.keepOriginalPositionY)
                {
                    num4 = 0;
                }
                else if (animationClipSettings.heightFromFeet)
                {
                    num4 = 2;
                }
                else
                {
                    num4 = 1;
                }
                switch (EditorGUILayout.Popup(!animationClipSettings.loopBlendPositionY ? styles.BasedUponPositionY : styles.BasedUponStartPositionY, num4, styles.BasedUponPositionYHumanOpt, new GUILayoutOption[0]))
                {
                    case 0:
                        animationClipSettings.keepOriginalPositionY = true;
                        animationClipSettings.heightFromFeet = false;
                        goto Label_04F1;

                    case 1:
                        animationClipSettings.keepOriginalPositionY = false;
                        animationClipSettings.heightFromFeet = false;
                        goto Label_04F1;
                }
                animationClipSettings.keepOriginalPositionY = false;
                animationClipSettings.heightFromFeet = true;
            }
            else
            {
                int num5 = !animationClipSettings.keepOriginalPositionY ? 1 : 0;
                num5 = EditorGUILayout.Popup(!animationClipSettings.loopBlendPositionY ? styles.BasedUponPositionY : styles.BasedUponStartPositionY, num5, styles.BasedUponPositionYOpt, new GUILayoutOption[0]);
                animationClipSettings.keepOriginalPositionY = num5 == 0;
            }
        Label_04F1:
            if (flag8)
            {
                EditorGUILayout.GetControlRect(new GUILayoutOption[0]);
            }
            else
            {
                animationClipSettings.level = EditorGUILayout.FloatField(styles.PositionOffsetY, animationClipSettings.level, new GUILayoutOption[0]);
            }
            EditorGUI.indentLevel--;
            EditorGUILayout.Space();
            GUILayout.Label("Root Transform Position (XZ)", EditorStyles.label, new GUILayoutOption[0]);
            EditorGUI.indentLevel++;
            Rect rect5 = EditorGUILayout.GetControlRect(new GUILayoutOption[0]);
            this.LoopToggle(rect5, styles.BakeIntoPosePositionXZ, ref animationClipSettings.loopBlendPositionXZ);
            int num6 = !animationClipSettings.keepOriginalPositionXZ ? 1 : 0;
            num6 = EditorGUILayout.Popup(!animationClipSettings.loopBlendPositionXZ ? styles.BasedUponPositionXZ : styles.BasedUponStartPositionXZ, num6, !isHumanMotion ? styles.BasedUponPositionXZOpt : styles.BasedUponPositionXZHumanOpt, new GUILayoutOption[0]);
            animationClipSettings.keepOriginalPositionXZ = num6 == 0;
            EditorGUI.indentLevel--;
            EditorGUILayout.Space();
            if (isHumanMotion)
            {
                this.LoopQualityLampAndCurve(r, info.loop, s_LoopMeterHint, changedStart, changedStop, this.m_QualityCurves[0]);
                this.LoopQualityLampAndCurve(rect3, info.loopOrientation, s_LoopOrientationMeterHint, changedStart, changedStop, this.m_QualityCurves[1]);
                this.LoopQualityLampAndCurve(rect4, info.loopPositionY, s_LoopPositionYMeterHint, changedStart, changedStop, this.m_QualityCurves[2]);
                this.LoopQualityLampAndCurve(rect5, info.loopPositionXZ, s_LoopPositionXZMeterHint, changedStart, changedStop, this.m_QualityCurves[3]);
            }
        Label_0689:
            if (isHumanMotion)
            {
                if (flag2)
                {
                    this.LoopQualityLampAndCurve(r, info.loop, s_LoopMeterHint, changedStart, changedStop, this.m_QualityCurves[0]);
                }
                animationClipSettings.mirror = EditorGUILayout.Toggle(styles.Mirror, animationClipSettings.mirror, new GUILayoutOption[0]);
            }
            if (flag2)
            {
                EditorGUILayout.Space();
                GUILayout.Label(styles.MotionCurves, EditorStyles.label, new GUILayoutOption[0]);
            }
            if (((this.m_ClipInfo == null) && flag4) && !flag5)
            {
                EditorGUILayout.Space();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                if (flag2)
                {
                    if (GUILayout.Button("Remove Root Motion Curves", new GUILayoutOption[0]))
                    {
                        AnimationUtility.SetGenerateMotionCurves(this.m_Clip, false);
                    }
                }
                else if (GUILayout.Button("Generate Root Motion Curves", new GUILayoutOption[0]))
                {
                    AnimationUtility.SetGenerateMotionCurves(this.m_Clip, true);
                }
                GUILayout.EndHorizontal();
            }
            string statsText = this.GetStatsText();
            if (statsText != string.Empty)
            {
                GUILayout.Label(statsText, EditorStyles.helpBox, new GUILayoutOption[0]);
            }
            EditorGUILayout.Space();
            if (this.m_ClipInfo != null)
            {
                this.InitMask();
                this.m_MaskInspector.showBody = isHumanMotion;
                int indentLevel = EditorGUI.indentLevel;
                changed = GUI.changed;
                m_MaskFoldout = EditorGUILayout.Foldout(m_MaskFoldout, styles.Mask);
                GUI.changed = changed;
                if ((this.m_ClipInfo.maskType == ClipAnimationMaskType.CreateFromThisModel) && !this.IsMaskUpToDate())
                {
                    GUILayout.BeginHorizontal(EditorStyles.helpBox, new GUILayoutOption[0]);
                    GUILayout.Label("Mask does not match hierarchy. Animation might not import correctly", EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[0]);
                    GUILayout.FlexibleSpace();
                    GUILayout.BeginVertical(new GUILayoutOption[0]);
                    GUILayout.Space(5f);
                    if (GUILayout.Button("Fix Mask", new GUILayoutOption[0]))
                    {
                        this.SetTransformMaskFromReference();
                        this.m_ClipInfo.MaskToClip(this.m_Mask);
                    }
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
                else if ((this.m_ClipInfo.maskType == ClipAnimationMaskType.CopyFromOther) && this.m_ClipInfo.MaskNeedsUpdating())
                {
                    GUILayout.BeginHorizontal(EditorStyles.helpBox, new GUILayoutOption[0]);
                    GUILayout.Label("Source Mask has changed since last import. It must be Updated", EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[0]);
                    GUILayout.FlexibleSpace();
                    GUILayout.BeginVertical(new GUILayoutOption[0]);
                    GUILayout.Space(5f);
                    if (GUILayout.Button("Update Mask", new GUILayoutOption[0]))
                    {
                        this.m_ClipInfo.MaskToClip(this.m_ClipInfo.maskSource);
                    }
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
                if (m_MaskFoldout)
                {
                    EditorGUI.indentLevel++;
                    this.m_MaskInspector.OnInspectorGUI();
                }
                EditorGUI.indentLevel = indentLevel;
            }
            if (this.m_ClipInfo != null)
            {
                changed = GUI.changed;
                m_ShowCurves = EditorGUILayout.Foldout(m_ShowCurves, styles.Curves);
                GUI.changed = changed;
                if (m_ShowCurves)
                {
                    this.CurveGUI();
                }
            }
            if (this.m_ClipInfo != null)
            {
                changed = GUI.changed;
                m_ShowEvents = EditorGUILayout.Foldout(m_ShowEvents, "Events");
                GUI.changed = changed;
                if (m_ShowEvents)
                {
                    this.EventsGUI();
                }
            }
            if (this.m_DraggingRangeBegin)
            {
                this.m_LoopTime = animationClipSettings.loopTime;
                this.m_LoopBlend = animationClipSettings.loopBlend;
                this.m_LoopBlendOrientation = animationClipSettings.loopBlendOrientation;
                this.m_LoopBlendPositionY = animationClipSettings.loopBlendPositionY;
                this.m_LoopBlendPositionXZ = animationClipSettings.loopBlendPositionXZ;
                animationClipSettings.loopTime = false;
                animationClipSettings.loopBlend = false;
                animationClipSettings.loopBlendOrientation = false;
                animationClipSettings.loopBlendPositionY = false;
                animationClipSettings.loopBlendPositionXZ = false;
                this.m_DraggingStartFrame = animationClipSettings.startTime * this.m_Clip.frameRate;
                this.m_DraggingStopFrame = animationClipSettings.stopTime * this.m_Clip.frameRate;
                animationClipSettings.startTime = 0f;
                animationClipSettings.stopTime = this.m_Clip.length;
                AnimationUtility.SetAnimationClipSettingsNoDirty(this.m_Clip, animationClipSettings);
                this.DestroyController();
            }
            if (this.m_DraggingRangeEnd)
            {
                animationClipSettings.loopTime = this.m_LoopTime;
                animationClipSettings.loopBlend = this.m_LoopBlend;
                animationClipSettings.loopBlendOrientation = this.m_LoopBlendOrientation;
                animationClipSettings.loopBlendPositionY = this.m_LoopBlendPositionY;
                animationClipSettings.loopBlendPositionXZ = this.m_LoopBlendPositionXZ;
            }
            if ((EditorGUI.EndChangeCheck() || this.m_DraggingRangeEnd) && !this.m_DraggingRange)
            {
                Undo.RegisterCompleteObjectUndo(this.m_Clip, "Muscle Clip Edit");
                AnimationUtility.SetAnimationClipSettingsNoDirty(this.m_Clip, animationClipSettings);
                EditorUtility.SetDirty(this.m_Clip);
                this.DestroyController();
            }
        }