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 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");
            }
        }
Beispiel #4
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);
        }
        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);
        }