예제 #1
0
        private void PreviewAnimation()
        {
            GUILayout.Label("Preview Animations", GUIResources.GetLightHeaderStyle_MD());
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Preview") && creator.gameObjectTransform != null)
            {
                PreviewButtonAction();
            }
            if (GUILayout.Button("Play") && creator.gameObjectTransform != null)
            {
                PlayButtonAction();
            }

            if (GUILayout.Button("Pause"))
            {
                PauseButtonAction();
            }
            if (GUILayout.Button("Stop") && creator.gameObjectTransform != null)
            {
                StopButtonAction();
            }
            //if (GUILayout.Button("Destory graph"))
            //{

            //}
            GUILayout.EndHorizontal();

            //sliderTime = EditorGUILayout.Slider(sliderTime, 0f, maxSliderTime);
        }
        private void OnGUI()
        {
            GUI.DrawTexture(leftSpace, GUIResources.GetMediumTexture_1());
            GUI.DrawTexture(middleSpace, GUIResources.GetGraphSpaceTexture());
            GUI.DrawTexture(rightSpace, GUIResources.GetMediumTexture_1());


            FitRects();
            Resizing(Event.current);

            leftWidthFactor  = leftSpace.width / this.position.width;
            rightWidthFactor = rightSpace.width / this.position.width;

            Event e = Event.current;

            graphSpace.Draw(middleSpace);
            DrawLeftSpace(e);
            DrawRightSpace(e);

            graphSpace.UserInput(e, middleSpace, this);

            if (animator != null)
            {
                EditorUtility.SetDirty(animator);
            }
        }
        private void OnGUI()
        {
            Event e = Event.current;

            GUI.DrawTexture(leftSpace, GUIResources.GetMediumTexture_1());
            GUI.DrawTexture(rightSpace, GUIResources.GetMediumTexture_2());

            FitRects();
            ResizeRects(e);

            resizeFactor = leftSpace.width / this.position.width;

            DoLayoutLeftMenu(e);
            DoLayoutRightMenu(e);

            AnimationPlaying();
            OnCurrentAnimationTimeChange();


            if (editedData != null)
            {
                EditorUtility.SetDirty(editedData);
                Undo.RecordObject(editedData, "MM_Data editor Change");
            }
        }
        public void Draw(Rect rect)
        {
            GUILayoutElements.DrawGrid(
                rect,
                20f,
                20f,
                0.5f,
                new Color(0.3f, 0.3f, 0.3f),
                selectedLayer != null ? selectedLayer.zoom : 1.0f
                );
            if (selectedLayer != null)
            {
                EditorZoomArea.Begin(selectedLayer.zoom, rect);

                DrawConnections();
                DrawStates();
                DrawTransitionToMousePos(mousePosition);

                if (multipleSelection)
                {
                    GUI.Box(selectionArea, "", GUIResources.GetSelectionArea());
                }

                EditorZoomArea.End();
            }
        }
예제 #5
0
 private void DrawTexturesInRects()
 {
     GUI.DrawTexture(creatorPlacing, GUIResources.GetDarkTexture());
     GUI.DrawTexture(creatorTypeSelecting, GUIResources.GetGraphSpaceTexture());
     GUI.DrawTexture(elementsListSection, GUIResources.GetMediumTexture_2());
     GUI.DrawTexture(elementOptionsSection, GUIResources.GetMediumTexture_1());
 }
예제 #6
0
        public static void DrawTreesElements(DataCreator creator, EditorWindow editor)
        {
            if (creator.selectedBlendTree == -1 || creator.blendTrees.Count == 0 || creator.selectedBlendTree >= creator.blendTrees.Count)
            {
                creator.selectedBlendTree = -1;
                GUILayout.Label("No blend tree item is selected");
                return;
            }

            BlendTreeInfo blendTree = creator.blendTrees[creator.selectedBlendTree];

            GUILayoutElements.DrawHeader(blendTree.name, GUIResources.GetLightHeaderStyle_MD());
            blendTree.name = EditorGUILayout.TextField(
                new GUIContent("Blend Tree name"),
                blendTree.name
                );

            blendTree.findInYourself  = EditorGUILayout.Toggle(new GUIContent("Find in yourself"), blendTree.findInYourself);
            blendTree.blendToYourself = EditorGUILayout.Toggle(new GUIContent("Blend to yourself"), blendTree.blendToYourself);

            blendTree.useSpaces = EditorGUILayout.Toggle(new GUIContent("Use spaces"), blendTree.useSpaces);
            if (blendTree.useSpaces)
            {
                if (blendTree.clips.Count == 2)
                {
                    blendTree.spaces = EditorGUILayout.IntField(new GUIContent("Spaces"), blendTree.spaces);
                }
                else
                {
                    GUILayout.Label("You can use \"Spaces\" with only 2 animations!");
                }
            }

            DrawElement(blendTree, creator.selectedBlendTree);
        }
        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 DrawConnections()
        {
            //float lineLength = 100f;
            foreach (MotionMatchingNode n in selectedLayer.nodes)
            {
                if (n.nodeType != MotionMatchingNodeType.Portal)
                {
                    foreach (Transition t in selectedLayer.states[n.stateIndex].transitions)
                    {
                        int toNodeIndex = 0;
                        for (int i = 0; i < selectedLayer.nodes.Count; i++)
                        {
                            if (selectedLayer.nodes[i].ID == t.nodeID)
                            {
                                toNodeIndex = i;
                                break;
                            }
                        }


                        t.transitionRect.position = (n.output.center + selectedLayer.nodes[toNodeIndex].input.center) / 2f - t.transitionRect.size / 2f;

                        if (t == selectedTransition)
                        {
                            DrawTransition(
                                t.transitionRect,
                                n.output.center,
                                selectedLayer.nodes[toNodeIndex].input.center,
                                Color.yellow,
                                GUIResources.GetSelectedConnectionTexture()
                                );
                        }
                        else if (selectedLayer.nodes[toNodeIndex].nodeType == MotionMatchingNodeType.Portal)
                        {
                            DrawTransition(
                                t.transitionRect,
                                n.output.center,
                                selectedLayer.nodes[toNodeIndex].input.center,
                                Color.green,
                                GUIResources.GetPortalConnectionTexture()
                                );
                        }
                        else
                        {
                            DrawTransition(
                                t.transitionRect,
                                n.output.center,
                                selectedLayer.nodes[toNodeIndex].input.center,
                                Color.white,
                                GUIResources.GetNormalConnectionTexture()
                                );
                        }
                    }
                }
            }
        }
예제 #10
0
        private static void DrawElement(BlendTreeInfo element, int elementIndex)
        {
            GUILayout.Space(5);

            GUILayoutElements.DrawHeader(
                "Animation clips",
                GUIResources.GetLightHeaderStyle_MD()
                );

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Clip", GUILayout.Width(100)))
            {
                element.AddClip(null);
            }
            if (GUILayout.Button("Clear clips", GUILayout.Width(100)))
            {
                element.ClearClips();
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5);
            for (int i = 0; i < element.clips.Count; i++)
            {
                GUILayout.BeginHorizontal();
                element.clips[i] = (AnimationClip)EditorGUILayout.ObjectField(element.clips[i], typeof(AnimationClip), true);
                if (GUILayout.Button("X", GUILayout.Width(20)))
                {
                    element.RemoveClip(i);
                    i--;
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(5);

            GUILayoutElements.DrawHeader(
                "Clips weights",
                GUIResources.GetLightHeaderStyle_MD()
                );
            GUILayout.Space(5);
            for (int weightIndex = 0; weightIndex < element.clipsWeights.Count; weightIndex++)
            {
                if (element.clips[weightIndex] != null)
                {
                    GUILayout.Label(new GUIContent(element.clips[weightIndex].name + " weight"));
                    element.clipsWeights[weightIndex] = EditorGUILayout.Slider(
                        element.clipsWeights[weightIndex],
                        0,
                        1f
                        );
                }
            }
            GUILayout.Space(10);
        }
        public void Draw(Rect rect, ref float resizeFactor, EditorWindow window)
        {
            GUI.DrawTexture(rect, GUIResources.GetMediumTexture_1());
            GUILayout.BeginArea(rect);

            if (animator != null)
            {
                GUILayout.Space(5);
                GUILayout.BeginHorizontal();

                if (GUILayout.Button("<", GUILayout.Width(20)))
                {
                    foldSpace    = true;
                    foldingSpeed = resizeFactor / 2f;
                }

                GUILayout.Space(5);

                toolbarOption = GUILayout.Toolbar(toolbarOption, toolBarStrings);

                if (foldSpace)
                {
                    resizeFactor -= (foldingSpeed * Time.deltaTime);
                    resizeFactor  = Mathf.Clamp(resizeFactor, 0f, float.MaxValue);
                    window.Repaint();
                    if (resizeFactor == 0)
                    {
                        foldSpace = false;
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(5);

                scroll = EditorGUILayout.BeginScrollView(scroll);
                switch (toolbarOption)
                {
                case 0:
                    DrawLayers(rect, ref window);
                    break;

                case 1:
                    DrawValues();
                    break;
                }

                EditorGUILayout.EndScrollView();
            }

            GUILayout.EndArea();
        }
        private void SectionOptionsLeftMenu()
        {
            bool result;

            GUILayout.BeginVertical();

            // Selecting Not Looking for new pose section
            result = selectedSectionType == SectionSelectedType.NotLookingForNewPoseSection;
            if (GUILayoutElements.DrawHeader(
                    "NotLookingForNewPose",
                    GUIResources.GetLightHeaderStyle_MD(),
                    GUIResources.GetDarkHeaderStyle_MD(),
                    result
                    ))
            {
                selectedSectionType  = SectionSelectedType.NotLookingForNewPoseSection;
                selectedSectionIndex = -1;
            }
            GUILayout.Space(betweenSectionsSpace);
            // Selecting Never Looking for new pose section
            result = selectedSectionType == SectionSelectedType.NeverLookingForNewPoseSection;
            if (GUILayoutElements.DrawHeader(
                    "NeverChecking",
                    GUIResources.GetLightHeaderStyle_MD(),
                    GUIResources.GetDarkHeaderStyle_MD(),
                    result
                    ))
            {
                selectedSectionType  = SectionSelectedType.NeverLookingForNewPoseSection;
                selectedSectionIndex = -1;
            }
            GUILayout.Space(betweenSectionsSpace);
            // Selecting other sections
            result = selectedSectionType == SectionSelectedType.NormalSection;

            for (int i = 0; i < editedData.sections.Count; i++)
            {
                if (GUILayoutElements.DrawHeader(
                        editedData.sections[i].sectionName,
                        GUIResources.GetLightHeaderStyle_MD(),
                        GUIResources.GetDarkHeaderStyle_MD(),
                        result && i == selectedSectionIndex
                        ))
                {
                    selectedSectionType  = SectionSelectedType.NormalSection;
                    selectedSectionIndex = i;
                }
                GUILayout.Space(betweenSectionsSpace);
            }
            GUILayout.EndVertical();
        }
        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 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 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);
                });
            }
        }
 private void DrawStates()
 {
     foreach (MotionMatchingNode node in selectedLayer.nodes)
     {
         node.Draw(
             selectedLayer.startStateIndex == node.stateIndex && node.nodeType != MotionMatchingNodeType.Portal,
             IsNodeSelected(node),
             node.stateIndex >= 0 && node.stateIndex < selectedLayer.states.Count ? selectedLayer.states[node.stateIndex].GetName() : "",
             GUIResources.SelectedNodeStyle(),
             GUIResources.StartNodeStyle(),
             GUIResources.NormalNodeStyle(),
             GUIResources.PortalNodeStyle(),
             GUIResources.ContactNodeStyle(),
             GUIResources.InputPointStyle(),
             GUIResources.OutputPointStyle(),
             GUIResources.NodeTextStyle()
             );
     }
 }
        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);
        }
        public static void DrawOptions(DataCreator creator)
        {
            float space = 5f;

            GUILayout.Space(space);
            GUILayoutElements.DrawHeader(
                "Options",
                GUIResources.GetLightHeaderStyle_MD(),
                GUIResources.GetDarkHeaderStyle_MD(),
                ref creator.basicOptionFold
                );
            if (creator.basicOptionFold)
            {
                DrawBasicOptions(creator);
            }

            GUILayout.Space(space);
            GUILayoutElements.DrawHeader(
                "Bones used to motion matching",
                GUIResources.GetLightHeaderStyle_MD(),
                GUIResources.GetDarkHeaderStyle_MD(),
                ref creator.maskFold
                );

            if (creator.maskFold)
            {
                DrawNeededBones(creator);
            }

            GUILayout.Space(space);
            GUILayoutElements.DrawHeader(
                "Trajectory Times",
                GUIResources.GetLightHeaderStyle_MD(),
                GUIResources.GetDarkHeaderStyle_MD(),
                ref creator.trajectoryFold
                );

            if (creator.trajectoryFold)
            {
                DrawTrajectoryTimes(creator);
            }
        }
        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);
            }
        }
예제 #20
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();
        }
        private static void DrawSequence(DataCreator creator, AnimationsSequence seq, int index, float rectWidth)
        {
            if (seq.findPoseInClip.Count != seq.clips.Count)
            {
                for (int i = 0; i < seq.clips.Count; i++)
                {
                    seq.findPoseInClip.Add(true);
                }
            }
            GUILayoutElements.DrawHeader(
                seq.name,
                GUIResources.GetLightHeaderStyle_MD()
                );

            GUILayout.Space(5);

            seq.name = EditorGUILayout.TextField(
                new GUIContent("Animation sequence name"),
                seq.name
                );

            //seq.loop = EditorGUILayout.Toggle(
            //    new GUIContent("Loop"),
            //    seq.loop
            //    );

            seq.findInYourself  = EditorGUILayout.Toggle(new GUIContent("Find in yourself"), seq.findInYourself);
            seq.blendToYourself = EditorGUILayout.Toggle(new GUIContent("Blend to yourself"), seq.blendToYourself);

            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add clip"))
            {
                seq.AddClip(null);
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5);
            float floatWidth  = 60f;
            float buttonWidth = 25f;
            float findPose    = 60f;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Animation");
            GUILayout.Label("Find pose", GUILayout.Width(findPose));
            GUILayout.Label("Start", GUILayout.Width(floatWidth));
            GUILayout.Label("End", GUILayout.Width(floatWidth));
            GUILayout.Label("Blend", GUILayout.Width(floatWidth));
            GUILayout.Space(buttonWidth);
            GUILayout.EndHorizontal();
            for (int i = 0; i < seq.clips.Count; i++)
            {
                GUILayout.BeginHorizontal();
                //GUILayout.Label(string.Format("{0}.", i + 1));
                seq.clips[i] = (AnimationClip)EditorGUILayout.ObjectField(
                    seq.clips[i],
                    typeof(AnimationClip),
                    true
                    );

                seq.findPoseInClip[i] = EditorGUILayout.Toggle(seq.findPoseInClip[i], GUILayout.Width(findPose));

                float x = seq.neededInfo[i].x;
                float y = seq.neededInfo[i].y;
                float z = seq.neededInfo[i].z;

                //GUILayout.Label("Start time");
                x = EditorGUILayout.FloatField(x, GUILayout.Width(floatWidth));
                //GUILayout.Label("Blend start time");
                y = EditorGUILayout.FloatField(y, GUILayout.Width(floatWidth));
                //GUILayout.Label("Blend time");
                z = EditorGUILayout.FloatField(z, GUILayout.Width(floatWidth));

                seq.neededInfo[i] = new Vector3(x, y, z);

                if (GUILayout.Button("X", GUILayout.Width(buttonWidth)))
                {
                    seq.RemoveAnimationsAt(i);
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);

            //deltaTimeCaculation = Time.realtimeSinceStartup;

            seq.CalculateLength();
            GUILayout.Label(string.Format("Sequence length: \t {0}", seq.length));


            GUILayout.Space(10);
        }
        private static void DrawNeededBones(DataCreator creator)
        {
            GUILayout.BeginHorizontal();
            creator.avatarMask = (AvatarMask)EditorGUILayout.ObjectField(
                new GUIContent("Skeleton Mask"),
                creator.avatarMask,
                typeof(AvatarMask),
                true
                );
            GUILayout.EndHorizontal();
            GUILayout.Space(5);

            int activeBones = 0;

            if (creator.bonesWeights == null)
            {
                creator.bonesWeights = new List <Vector2>();
            }
            else if (creator.avatarMask != null)
            {
                if (creator.gameObjectTransform != null)
                {
                    for (int i = 0; i < creator.avatarMask.transformCount; i++)
                    {
                        if (creator.avatarMask.GetTransformActive(i))
                        {
                            if (creator.gameObjectTransform.Find(creator.avatarMask.GetTransformPath(i)) != null)
                            {
                                string name = creator.gameObjectTransform.Find(creator.avatarMask.GetTransformPath(i)).name;

                                if (name != creator.gameObjectTransform.name)
                                {
                                    activeBones++;
                                    GUILayoutElements.DrawHeader(string.Format("{0} weights", name), GUIResources.GetLightHeaderStyle_SM());
                                    if ((creator.bonesWeights.Count) < activeBones)
                                    {
                                        creator.bonesWeights.Add(Vector2.one);
                                    }

                                    //float posW = creator.bonesWeights[activeBones - 1].x;
                                    //float velW = creator.bonesWeights[activeBones - 1].y;

                                    //GUILayout.BeginHorizontal();
                                    //GUILayout.Label(new GUIContent("Position"), GUILayout.Width(75));
                                    //posW = EditorGUILayout.Slider(
                                    //    posW, 0, 1f
                                    //    );
                                    //GUILayout.EndHorizontal();

                                    //GUILayout.BeginHorizontal();
                                    //GUILayout.Label(new GUIContent("Velocity"), GUILayout.Width(75));
                                    //velW = EditorGUILayout.Slider(
                                    //    velW, 0, 1f
                                    //    );
                                    //GUILayout.EndHorizontal();

                                    //creator.bonesWeights[activeBones - 1] = new Vector2(posW, velW);
                                    GUILayout.Space(5);
                                }
                            }
                            else
                            {
                                Debug.LogWarning("Game object transform is wrong");
                                return;
                            }
                        }
                    }

                    if (creator.bonesWeights.Count > activeBones)
                    {
                        for (; creator.bonesWeights.Count > activeBones;)
                        {
                            creator.bonesWeights.RemoveAt(creator.bonesWeights.Count - 1);
                        }
                    }
                }
            }

            if (activeBones > 10)
            {
                GUILayout.Label("Max number of matched bones is equal 10");
            }
        }
        public static void DrawAnimationList(DataCreator creator)
        {
            GUILayout.Space(5);
            GUILayout.Label("Drag And droop animations here", GUIResources.GetLightHeaderStyle_MD());
            Event e = Event.current;


            Rect dropRect = GUILayoutUtility.GetLastRect();

            if (dropRect.Contains(e.mousePosition))
            {
                if (Event.current.type == EventType.DragUpdated)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    Event.current.Use();
                }
                else if (Event.current.type == EventType.DragPerform)
                {
                    bool correctData             = true;
                    List <AnimationClip> newData = new List <AnimationClip>();
                    for (int i = 0; i < DragAndDrop.objectReferences.Length; i++)
                    {
                        try
                        {
                            newData.Add((AnimationClip)DragAndDrop.objectReferences[i]);
                        }
                        catch (Exception)
                        {
                            correctData = false;
                            break;
                        }
                    }

                    if (correctData)
                    {
                        for (int i = 0; i < newData.Count; i++)
                        {
                            creator.clips.Add(newData[i]);
                        }
                    }
                    Event.current.Use();
                }
            }

            GUILayout.Space(10);

            for (int i = 0; i < creator.clips.Count; i++)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(10);
                EditorGUILayout.ObjectField(creator.clips[i], typeof(AnimationClip), false);
                if (GUILayout.Button("X", GUILayout.Width(25)))
                {
                    creator.clips.RemoveAt(i);
                    i--;
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Clear"))
            {
                creator.clips.Clear();
            }
            if (GUILayout.Button("Remove nulls"))
            {
                for (int i = 0; i < creator.clips.Count; i++)
                {
                    if (creator.clips[i] == null)
                    {
                        creator.clips.RemoveAt(i);
                        i--;
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(5);
        }
        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;
            }
        }
예제 #25
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);
            }
        }
예제 #26
0
        public static void DrawTreesList(DataCreator creator, EditorWindow editor)
        {
            GUILayoutElements.DrawHeader("Blend Trees", GUIResources.GetDarkHeaderStyle_MD());

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add"))
            {
                creator.blendTrees.Add(new BlendTreeInfo("New info"));
            }
            //if (GUILayout.Button("Clear"))
            //{
            //    creator.blendTrees.Clear();
            //}
            GUILayout.EndHorizontal();
            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Find", GUILayout.Width(50));
            creator.findingBlendTree = GUILayout.TextField(creator.findingBlendTree);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            for (int i = 0; i < creator.blendTrees.Count; i++)
            {
                if (creator.findingBlendTree != "" && !creator.blendTrees[i].name.ToLower().Contains(creator.findingBlendTree.ToLower()))
                {
                    continue;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Space(5);
                GUILayout.Label(
                    creator.blendTrees[i].name,
                    i == creator.selectedBlendTree ? GUIResources.GetDarkHeaderStyle_SM() : GUIResources.GetLightHeaderStyle_SM()
                    );


                Event e = Event.current;
                Rect  r = GUILayoutUtility.GetLastRect();

                if (r.Contains(e.mousePosition) && e.type == EventType.MouseDown && e.button == 0)
                {
                    if (creator.selectedBlendTree == i)
                    {
                        creator.selectedBlendTree = -1;
                    }
                    else
                    {
                        creator.selectedBlendTree = i;
                    }
                    e.Use();
                    editor.Repaint();
                }

                if (GUILayout.Button("Copy", GUILayout.Width(40)))
                {
                    creator.blendTrees.Add(new BlendTreeInfo(creator.blendTrees[i].name + "_NEW"));
                    for (int j = 0; j < creator.blendTrees[i].clips.Count; j++)
                    {
                        creator.blendTrees[creator.blendTrees.Count - 1].AddClip(creator.blendTrees[i].clips[j]);
                    }
                }

                if (GUILayout.Button("X", GUILayout.Width(25)))
                {
                    creator.blendTrees.RemoveAt(i);
                    i--;
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(5);
            }
            GUILayout.Space(5);
        }
        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);
        }
        public override void OnInspectorGUI()
        {
            GUILayoutElements.DrawHeader(data.name, GUIResources.GetMediumHeaderStyle_LG());

            scroll = GUILayout.BeginScrollView(scroll);

            GUILayout.Space(10);
            if (GUILayoutElements.DrawHeader(
                    "Basic options",
                    GUIResources.GetMediumHeaderStyle_MD(),
                    GUIResources.GetLightHeaderStyle_MD(),
                    ref this.data.basicOptionsFold
                    ))
            {
                DrawBasicOptions();
            }
            GUILayout.Space(5);
            if (GUILayoutElements.DrawHeader(
                    "Sections",
                    GUIResources.GetMediumHeaderStyle_MD(),
                    GUIResources.GetLightHeaderStyle_MD(),
                    ref data.sectionFold
                    ))
            {
                DrawSections();
            }

            GUILayout.Space(5);
            if (GUILayoutElements.DrawHeader(
                    "Data type options",
                    GUIResources.GetMediumHeaderStyle_MD(),
                    GUIResources.GetLightHeaderStyle_MD(),
                    ref data.additionalOptionsFold
                    ))
            {
                DrawTypeInfo();
            }

            GUILayout.Space(5);

            if (GUILayoutElements.DrawHeader(
                    "Contact Points",
                    GUIResources.GetMediumHeaderStyle_MD(),
                    GUIResources.GetLightHeaderStyle_MD(),
                    ref data.contactPointsFold
                    ))
            {
                DrawContactPoints();
            }

            GUILayout.EndScrollView();
            GUILayout.Space(20);

            drawRawOptions = EditorGUILayout.Toggle(new GUIContent("Draw raw options"), drawRawOptions);
            if (drawRawOptions)
            {
                base.OnInspectorGUI();
            }

            if (data != null)
            {
                EditorUtility.SetDirty(data);
            }
        }
        public static void DrawSequencesList(DataCreator creator, EditorWindow editor)
        {
            GUILayoutElements.DrawHeader("Sequences", GUIResources.GetDarkHeaderStyle_MD());

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add"))
            {
                creator.sequences.Add(new AnimationsSequence("new Sequence"));
            }
            //if (GUILayout.Button("Clear"))
            //{
            //    creator.sequences.Clear();
            //}
            GUILayout.EndHorizontal();
            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Find", GUILayout.Width(50));
            creator.findingSequence = EditorGUILayout.TextField(creator.findingSequence);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            for (int i = 0; i < creator.sequences.Count; i++)
            {
                if (creator.findingSequence != "" && !creator.sequences[i].name.ToLower().Contains(creator.findingSequence.ToLower()))
                {
                    continue;
                }
                GUILayout.BeginHorizontal();
                GUILayout.Space(5);
                GUILayout.Label(
                    creator.sequences[i].name,
                    i == creator.selectedSequence ? GUIResources.GetDarkHeaderStyle_SM() : GUIResources.GetLightHeaderStyle_SM()
                    );


                Event e = Event.current;
                Rect  r = GUILayoutUtility.GetLastRect();

                if (r.Contains(e.mousePosition) && e.type == EventType.MouseDown && e.button == 0)
                {
                    if (creator.selectedSequence == i)
                    {
                        creator.selectedSequence = -1;
                    }
                    else
                    {
                        creator.selectedSequence = i;
                    }
                    e.Use();
                    editor.Repaint();
                }

                if (GUILayout.Button("Copy", GUILayout.Width(40)))
                {
                    AnimationsSequence info = new AnimationsSequence(creator.sequences[i].name + "_New");

                    for (int j = 0; j < creator.sequences[i].clips.Count; j++)
                    {
                        info.clips.Add(creator.sequences[i].clips[j]);
                        info.neededInfo.Add(creator.sequences[i].neededInfo[j]);
                        info.findPoseInClip.Add(creator.sequences[i].findPoseInClip[j]);
                    }

                    creator.sequences.Insert(i + 1, info);
                }
                if (GUILayout.Button("X", GUILayout.Width(25)))
                {
                    creator.sequences.RemoveAt(i);
                    i--;
                }
                GUILayout.Space(10);
                GUILayout.EndHorizontal();
                GUILayout.Space(5);
            }
            GUILayout.Space(5);
        }