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