UnityEditor.AnimationClipEditor.CurveGUI C# (CSharp) Method

CurveGUI() private method

private CurveGUI ( ) : void
return void
        private void CurveGUI()
        {
            if (this.m_ClipInfo != null)
            {
                if (this.m_AvatarPreview.timeControl.currentTime == float.NegativeInfinity)
                {
                    this.m_AvatarPreview.timeControl.Update();
                }
                float normalizedTime = this.m_AvatarPreview.timeControl.normalizedTime;
                for (int i = 0; i < this.m_ClipInfo.GetCurveCount(); i++)
                {
                    GUILayout.Space(5f);
                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    GUILayoutOption[] optionArray1 = new GUILayoutOption[] { GUILayout.Width(17f) };
                    if (GUILayout.Button(GUIContent.none, "OL Minus", optionArray1))
                    {
                        this.m_ClipInfo.RemoveCurve(i);
                    }
                    else
                    {
                        GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(125f) };
                        GUILayout.BeginVertical(optionArray2);
                        string curveName = this.m_ClipInfo.GetCurveName(i);
                        string name = EditorGUILayout.DelayedTextField(curveName, null, EditorStyles.textField, new GUILayoutOption[0]);
                        if (curveName != name)
                        {
                            this.m_ClipInfo.SetCurveName(i, name);
                        }
                        SerializedProperty curveProperty = this.m_ClipInfo.GetCurveProperty(i);
                        AnimationCurve animationCurveValue = curveProperty.animationCurveValue;
                        int length = animationCurveValue.length;
                        bool disabled = false;
                        int index = length - 1;
                        for (int j = 0; j < length; j++)
                        {
                            if (Mathf.Abs((float) (animationCurveValue.keys[j].time - normalizedTime)) < 0.0001f)
                            {
                                disabled = true;
                                index = j;
                                break;
                            }
                            if (animationCurveValue.keys[j].time > normalizedTime)
                            {
                                index = j;
                                break;
                            }
                        }
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        if (GUILayout.Button(prevKeyContent, new GUILayoutOption[0]) && (index > 0))
                        {
                            index--;
                            this.m_AvatarPreview.timeControl.normalizedTime = animationCurveValue.keys[index].time;
                        }
                        if (GUILayout.Button(nextKeyContent, new GUILayoutOption[0]))
                        {
                            if (disabled && (index < (length - 1)))
                            {
                                index++;
                            }
                            this.m_AvatarPreview.timeControl.normalizedTime = animationCurveValue.keys[index].time;
                        }
                        EditorGUI.BeginDisabledGroup(!disabled);
                        string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString;
                        EditorGUI.kFloatFieldFormatString = "n3";
                        float num6 = animationCurveValue.Evaluate(normalizedTime);
                        GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width(60f) };
                        float num7 = EditorGUILayout.FloatField(num6, optionArray3);
                        EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString;
                        EditorGUI.EndDisabledGroup();
                        bool flag2 = false;
                        if (num6 != num7)
                        {
                            if (disabled)
                            {
                                animationCurveValue.RemoveKey(index);
                            }
                            flag2 = true;
                        }
                        EditorGUI.BeginDisabledGroup(disabled);
                        if (GUILayout.Button(addKeyframeContent, new GUILayoutOption[0]))
                        {
                            flag2 = true;
                        }
                        EditorGUI.EndDisabledGroup();
                        if (flag2)
                        {
                            Keyframe key = new Keyframe {
                                time = normalizedTime,
                                value = num7,
                                inTangent = 0f,
                                outTangent = 0f
                            };
                            animationCurveValue.AddKey(key);
                            this.m_ClipInfo.SetCurve(i, animationCurveValue);
                            AnimationCurvePreviewCache.ClearCache();
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.EndVertical();
                        Rect ranges = new Rect();
                        GUILayoutOption[] optionArray4 = new GUILayoutOption[] { GUILayout.Height(40f) };
                        EditorGUILayout.CurveField(curveProperty, EditorGUI.kCurveColor, ranges, optionArray4);
                        Rect lastRect = GUILayoutUtility.GetLastRect();
                        length = animationCurveValue.length;
                        Handles.color = Color.red;
                        Handles.DrawLine(new Vector3(lastRect.x + (normalizedTime * lastRect.width), lastRect.y, 0f), new Vector3(lastRect.x + (normalizedTime * lastRect.width), lastRect.y + lastRect.height, 0f));
                        for (int k = 0; k < length; k++)
                        {
                            float time = animationCurveValue.keys[k].time;
                            Handles.color = Color.white;
                            Handles.DrawLine(new Vector3(lastRect.x + (time * lastRect.width), (lastRect.y + lastRect.height) - 10f, 0f), new Vector3(lastRect.x + (time * lastRect.width), lastRect.y + lastRect.height, 0f));
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(17f) };
                if (GUILayout.Button(GUIContent.none, "OL Plus", options))
                {
                    this.m_ClipInfo.AddCurve();
                }
                GUILayout.EndHorizontal();
            }
        }