private void DrawContactsOptionsOnRightMenu()
        {
            if (contactPointsRL == null || isDataSwitched)
            {
                contactPointsRL = new ReorderableList(editedData.contactPoints, typeof(MotionMatchingContact), true, false, true, true);
            }

            HandleContactPointsReorderbleList(contactPointsRL, editedData, 2);
            contactPointsRL.DoLayoutList();

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Copy Contacts Settings", GUIResources.Button_MD()))
            {
                if (dataToCopyOptions != null)
                {
                    editedData.contactPoints.Clear();
                    for (int i = 0; i < dataToCopyOptions.contactPoints.Count; i++)
                    {
                        editedData.contactPoints.Add(dataToCopyOptions.contactPoints[i]);
                    }
                }
            }

            dataToCopyOptions = (MotionMatchingData)EditorGUILayout.ObjectField(dataToCopyOptions, typeof(MotionMatchingData), true);
            GUILayout.EndHorizontal();

            GUILayout.Space(10);
        }
 private void DrawRightContactsOptionsAboveScrollOptions()
 {
     GUILayout.BeginHorizontal();
     if (GUILayout.Button("Set Contact Start Time", GUIResources.Button_MD()) && editedData != null)
     {
         if (contactPointsRL != null)
         {
             if (0 <= contactPointsRL.index && contactPointsRL.index < editedData.contactPoints.Count)
             {
                 MotionMatchingContact cp = editedData.contactPoints[contactPointsRL.index];
                 cp.SetStartTime(currentAnimaionTime);
                 editedData.contactPoints[contactPointsRL.index] = cp;
             }
         }
     }
     if (GUILayout.Button("Set Contact End Time", GUIResources.Button_MD()) && editedData != null)
     {
         if (contactPointsRL != null)
         {
             if (0 <= contactPointsRL.index && contactPointsRL.index < editedData.contactPoints.Count)
             {
                 MotionMatchingContact cp = editedData.contactPoints[contactPointsRL.index];
                 cp.SetEndTime(currentAnimaionTime);
                 editedData.contactPoints[contactPointsRL.index] = cp;
             }
         }
     }
     GUILayout.EndHorizontal();
 }
        private void DrawRightSectionsOptionsAboveScroll()
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Sort Intervals", GUIResources.Button_MD()))
            {
                selectedSection.timeIntervals.Sort(delegate(float2 x, float2 y)
                {
                    if (x.x < y.x)
                    {
                        return(-1);
                    }
                    return(1);
                });
            }
            if (GUILayout.Button("Set Interval Start", GUIResources.Button_MD()))
            {
                if (sectionIntervalsRL != null && selectedSection != null)
                {
                    int selectedIntervalIndex = sectionIntervalsRL.index;
                    if (0 <= selectedIntervalIndex && selectedIntervalIndex < selectedSection.timeIntervals.Count)
                    {
                        float2 newTimeInterval = new float2(
                            currentAnimaionTime,
                            selectedSection.timeIntervals[selectedIntervalIndex].y
                            );

                        selectedSection.timeIntervals[selectedIntervalIndex] = newTimeInterval;
                    }
                }
            }
            if (GUILayout.Button("Set Interval End", GUIResources.Button_MD()))
            {
                if (sectionIntervalsRL != null && selectedSection != null)
                {
                    int selectedIntervalIndex = sectionIntervalsRL.index;
                    if (0 <= selectedIntervalIndex && selectedIntervalIndex < selectedSection.timeIntervals.Count)
                    {
                        float2 newTimeInterval = new float2(
                            selectedSection.timeIntervals[selectedIntervalIndex].x,
                            currentAnimaionTime
                            );

                        selectedSection.timeIntervals[selectedIntervalIndex] = newTimeInterval;
                    }
                }
            }
            GUILayout.EndHorizontal();
        }
        private void DrawEventMarkersRightMenu()
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Event Marker", GUIResources.Button_MD()))
            {
                editedData.eventMarkers.Add(new MotionMatchingEventMarker(string.Format("EventMarker{0}", editedData.eventMarkers.Count), currentAnimaionTime));
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            for (int i = 0; i < editedData.eventMarkers.Count; i++)
            {
                GUILayout.BeginHorizontal();
                editedData.eventMarkers[i] = DrawEventMarker(editedData.eventMarkers[i]);

                if (GUILayout.Button("Set Event Marker time"))
                {
                    MotionMatchingEventMarker em = editedData.eventMarkers[i];
                    em.SetTime(currentAnimaionTime);
                    editedData.eventMarkers[i] = em;
                }
                GUILayout.Space(5);
                if (GUILayout.Button("X", GUILayout.Width(25f)))
                {
                    editedData.eventMarkers.RemoveAt(i);
                    i--;
                }

                GUILayout.EndHorizontal();
            }
            GUILayout.Space(10);
            if (GUILayout.Button("Sort Event Markers", GUIResources.Button_MD()))
            {
                editedData.eventMarkers.Sort(delegate(MotionMatchingEventMarker x, MotionMatchingEventMarker y)
                {
                    if (x.GetTime() <= y.GetTime())
                    {
                        return(-1);
                    }
                    return(1);
                });
            }
        }
예제 #5
0
        private void DrawElementListSection()
        {
            GUILayout.BeginArea(elementsListSection);
            scrollView_L = GUILayout.BeginScrollView(scrollView_L);
            switch (selectedCreator)
            {
            case 0:
                CreatorBasicOption.DrawOptions(this.creator);

                GUILayout.Space(10);

                if (GUILayout.Button("Calculate only clips", GUIResources.Button_MD()) && creator.gameObjectTransform != null)
                {
                    CalculateDataButton(true, false, false);
                }
                break;

            case 1:
                BlendTreesOptions.DrawTreesList(this.creator, this);

                if (GUILayout.Button("Calculate only Blend Trees", GUIResources.Button_MD()) && creator.gameObjectTransform != null)
                {
                    CalculateDataButton(false, true, false);
                }
                break;

            case 2:
                AnimationSequenceOptions.DrawSequencesList(this.creator, this);

                if (GUILayout.Button("Calculate only Sequences", GUIResources.Button_MD()) && creator.gameObjectTransform != null)
                {
                    CalculateDataButton(false, false, true);
                }
                break;
            }
            GUILayout.Space(10);
            GUILayout.EndScrollView();
            GUILayout.EndArea();
        }
예제 #6
0
        public override void OnInspectorGUI()
        {
            if (sectionsNames == null)
            {
                sectionsNames = new List <string>();
            }
            sectionsNames.Clear();

            for (int i = 1; i < data.sectionSettings.Count; i++)
            {
                sectionsNames.Add(data.sectionSettings[i].name);
            }

            GUILayoutElements.DrawHeader(data.name, GUIResources.GetMediumHeaderStyle_LG());

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Section", GUIResources.Button_MD()))
            {
                data.AddSection();
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(10);
            for (int i = 0; i < data.sectionSettings.Count; i++)
            {
                if (i == 0)
                {
                    GUILayoutElements.DrawHeader(
                        string.Format("{0}. {1}", i, data.sectionSettings[i].name),
                        GUIResources.GetMediumHeaderStyle_MD()
                        );
                    GUILayout.Space(5);
                    continue;
                }
                GUILayout.BeginHorizontal();
                GUILayoutElements.DrawHeader(
                    data.sectionSettings[i].name,
                    GUIResources.GetMediumHeaderStyle_MD(),
                    GUIResources.GetLightHeaderStyle_MD(),
                    ref data.sectionSettings[i].fold
                    );

                if (GUILayout.Button("X", GUILayout.Width(25), GUILayout.Height(25)))
                {
                    data.sectionSettings.RemoveAt(i);
                    i--;
                    continue;
                }
                GUILayout.EndHorizontal();

                if (data.sectionSettings[i].fold)
                {
                    GUILayout.Space(5);
                    DrawSectionSettings(data.sectionSettings[i], i);
                }
                GUILayout.Space(5);
            }

            GUILayout.Space(10);
            drawRawOption = EditorGUILayout.Toggle("Draw raw options", drawRawOption);

            if (drawRawOption)
            {
                base.OnInspectorGUI();
            }

            if (data != null)
            {
                EditorUtility.SetDirty(data);
            }
        }
        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 ContactsButtonOptions()
        {
            GUILayout.Space(5);

            switch (editedData.contactsType)
            {
            case ContactStateType.NormalContacts:
                if (GUILayout.Button("Sort contacts", GUIResources.Button_MD()) && editedData != null)
                {
                    editedData.contactPoints.Sort();
                }

                if (GUILayout.Button("Calculate Contacts", GUIResources.Button_MD()) && editedData != null && gameObject != null)
                {
                    if (gameObject == null)
                    {
                        Debug.LogWarning("Game object in MM Data Editor is NULL!");
                        return;
                    }
                    else
                    {
                        editedData.contactPoints.Sort();

                        MotionDataCalculator.CalculateContactPoints(
                            editedData,
                            editedData.contactPoints.ToArray(),
                            this.playableGraph,
                            this.gameObject
                            );

                        playableGraph.Initialize(gameObject);
                        playableGraph.CreateAnimationDataPlayables(editedData, currentAnimaionTime);
                    }
                }
                break;

            case ContactStateType.Impacts:
                if (GUILayout.Button("Sort impacts", GUIResources.Button_MD()) && editedData != null)
                {
                    editedData.contactPoints.Sort();
                }

                if (GUILayout.Button("Calculate Impacts", GUIResources.Button_MD()) && editedData != null && gameObject != null)
                {
                    if (gameObject == null)
                    {
                        Debug.LogWarning("Game object in MM Data Editor is NULL!");
                        return;
                    }
                    else
                    {
                        editedData.contactPoints.Sort();

                        MotionDataCalculator.CalculateImpactPoints(
                            editedData,
                            editedData.contactPoints.ToArray(),
                            this.playableGraph,
                            this.gameObject
                            );

                        playableGraph.Initialize(gameObject);
                        playableGraph.CreateAnimationDataPlayables(editedData, currentAnimaionTime);
                    }
                }
                break;
            }
        }