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 DrawSelectedSection(MM_DataSection section) { if (selectedSection != section) { selectedSection = section; sectionIntervalsRL = new ReorderableList(selectedSection.timeIntervals, typeof(float2), true, false, true, true); } HandleSectionIntervals(sectionIntervalsRL, editedData); sectionIntervalsRL.DoLayoutList(); GUILayout.Space(10); GUILayout.BeginHorizontal(); if (GUILayout.Button("Copy Section Settings", GUIResources.Button_MD())) { if (dataToCopyOptions != null) { switch (selectedSectionType) { case SectionSelectedType.NotLookingForNewPoseSection: editedData.notLookingForNewPose.timeIntervals.Clear(); for (int i = 0; i < dataToCopyOptions.notLookingForNewPose.timeIntervals.Count; i++) { editedData.notLookingForNewPose.timeIntervals.Add(new float2( dataToCopyOptions.notLookingForNewPose.timeIntervals[i].x, dataToCopyOptions.notLookingForNewPose.timeIntervals[i].y )); } break; case SectionSelectedType.NeverLookingForNewPoseSection: editedData.neverChecking.timeIntervals.Clear(); for (int i = 0; i < dataToCopyOptions.neverChecking.timeIntervals.Count; i++) { editedData.neverChecking.timeIntervals.Add(new float2( dataToCopyOptions.neverChecking.timeIntervals[i].x, dataToCopyOptions.neverChecking.timeIntervals[i].y )); } break; case SectionSelectedType.NormalSection: if (0 <= selectedSectionIndex && selectedSectionIndex < dataToCopyOptions.sections.Count) { editedData.sections[selectedSectionIndex].timeIntervals.Clear(); for (int i = 0; i < dataToCopyOptions.sections[selectedSectionIndex].timeIntervals.Count; i++) { editedData.AddSectionInterval( selectedSectionIndex, i, dataToCopyOptions.sections[selectedSectionIndex].timeIntervals[i] ); } } break; } } } dataToCopyOptions = (MotionMatchingData)EditorGUILayout.ObjectField(dataToCopyOptions, typeof(MotionMatchingData), true); GUILayout.EndHorizontal(); GUILayout.Space(10); }
private void DrawIntervalsTable(MM_DataSection section, int sectionIndex) { if (section.timeIntervals.Count == 0) { for (int frameIndex = 0; frameIndex < data.numberOfFrames; frameIndex++) { FrameData buffor = data[frameIndex]; buffor.sections.SetSection(sectionIndex, false); data.frames[frameIndex] = buffor; } } 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); if (section.SetTimeIntervalWithCheck(intervalIndex, new float2(min, max))) { for (int frameIndex = 0; frameIndex < data.numberOfFrames; frameIndex++) { ChangeSectionInFrame(frameIndex, sectionIndex); } } if (GUILayout.Button("X", GUILayout.Width(20))) { section.timeIntervals.RemoveAt(intervalIndex); intervalIndex = Mathf.Clamp(intervalIndex - 1, 0, int.MaxValue); for (int frameIndex = 0; frameIndex < data.numberOfFrames; frameIndex++) { ChangeSectionInFrame(frameIndex, sectionIndex); } } GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); if (GUILayout.Button("Add interval")) { if (section.timeIntervals.Count == 0) { section.timeIntervals.Add(new float2(0f, data.animationLength)); for (int frameIndex = 0; frameIndex < data.numberOfFrames; frameIndex++) { ChangeSectionInFrame(frameIndex, sectionIndex); } } else { section.timeIntervals.Add(section.timeIntervals[section.timeIntervals.Count - 1]); } } if (GUILayout.Button("Clear")) { section.timeIntervals.Clear(); } GUILayout.EndHorizontal(); }