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 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); }
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 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); }
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); } }
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 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); } }
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); }
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); }
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); } }