private void DrawNonEditableSection(MM_DataSection section, ref bool fold)
        {
            if (!GUILayoutElements.DrawHeader(
                    "Section :  " + section.sectionName,
                    GUIResources.GetMediumHeaderStyle_SM(),
                    GUIResources.GetLightHeaderStyle_SM(),
                    ref fold
                    ))
            {
                return;
            }
            for (int intervalIndex = 0; intervalIndex < section.timeIntervals.Count; intervalIndex++)
            {
                float min = section.timeIntervals[intervalIndex].x;
                float max = section.timeIntervals[intervalIndex].y;

                GUILayout.BeginHorizontal();
                min = EditorGUILayout.FloatField(Mathf.Clamp(min, 0f, max), GUILayout.Width(60));
                EditorGUILayout.MinMaxSlider(ref min, ref max, 0f, data.animationLength);
                max = EditorGUILayout.FloatField(Mathf.Clamp(max, min, data.animationLength), GUILayout.Width(60));

                min = (float)Math.Round(min, 4);
                max = (float)Math.Round(max, 4);

                section.SetTimeIntervalWithCheck(intervalIndex, new float2(min, max));

                if (GUILayout.Button("X", GUILayout.Width(20)))
                {
                    section.timeIntervals.RemoveAt(intervalIndex);
                    intervalIndex = Mathf.Clamp(intervalIndex - 1, 0, int.MaxValue);
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add interval"))
            {
                section.timeIntervals.Add(new float2(0f, data.animationLength));
            }
            if (GUILayout.Button("Clear"))
            {
                section.timeIntervals.Clear();
            }
            GUILayout.EndHorizontal();
        }
        private void DrawEditableSection(MM_DataSection section, ref int index)
        {
            GUILayout.BeginHorizontal();
            GUILayoutElements.DrawHeader(
                "Section " + index + ":  " + section.sectionName,
                GUIResources.GetLightHeaderStyle_SM(),
                GUIResources.GetMediumHeaderStyle_SM(),
                ref section.fold
                );
            if (index != 0)
            {
                if (GUILayout.Button("X", GUILayout.Width(20)))
                {
                    data.sections.RemoveAt(index);
                    OnRemoveSection(index);
                    index--;
                    return;
                }
            }
            GUILayout.EndHorizontal();

            if (section.fold)
            {
                return;
            }

            GUILayout.BeginHorizontal();

            if (index != 0)
            {
                section.sectionName = EditorGUILayout.TextField(new GUIContent("Section name"), section.sectionName);
                //if (GUILayout.Button("Remove", GUILayout.Width(60)))
                //{
                //    data.timeSection.RemoveAt(index);
                //    OnRemoveSection(index);
                //    return;
                //}
            }

            GUILayout.EndHorizontal();

            DrawIntervalsTable(section, index);
        }
        private void DrawSections()
        {
            GUILayout.Space(5);
            DrawNeverCheckingSecction(data.neverChecking, ref data.neverChecking.fold);
            GUILayout.Space(5);
            DrawNonEditableSection(data.notLookingForNewPose, ref data.notLookingForNewPose.fold);
            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayoutElements.DrawHeader("Editable sections:", GUIResources.GetMediumHeaderStyle_SM());
            if (GUILayout.Button("Add Section", GUILayout.Height(20)))
            {
                if (data.sections.Count < MotionMatchingData.maxSectionsCounts)
                {
                    data.sections.Add(new MM_DataSection("New Section"));
                    //OnAddSection(data.sections.Count - 1);
                }
                else
                {
                    Debug.LogWarning("AnimationData can contains max " + MotionMatchingData.maxSectionsCounts + " sections!");
                }
            }
            if (GUILayout.Button("Clear", GUILayout.Height(20)))
            {
                int removingIndex = 1;
                for (int i = 1; i < data.sections.Count; i++)
                {
                    data.sections.RemoveAt(i);
                    i--;
                    OnRemoveSection(removingIndex);
                    removingIndex++;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5);
            for (int i = 0; i < data.sections.Count; i++)
            {
                DrawEditableSection(data.sections[i], ref i);
                GUILayout.Space(5);
            }
        }