private void InspectEditor() { if (Target.Data == null) { return; } MotionData.Frame frame = Target.Data.GetFrame(Target.Timestamp); Utility.SetGUIColor(UltiDraw.Grey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.DarkGrey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.Mustard); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(Target.GetActor() == null ? UltiDraw.DarkRed : UltiDraw.White); EditorGUILayout.ObjectField("Actor", Target.GetActor(), typeof(Actor), true); Utility.ResetGUIColor(); Utility.SetGUIColor(Target.GetScene() == null ? UltiDraw.DarkRed : UltiDraw.White); EditorGUILayout.ObjectField("Scene", Target.GetScene(), typeof(Transform), true); Utility.ResetGUIColor(); EditorGUILayout.ObjectField("Data", Target.Data, typeof(MotionData), true); } Utility.SetGUIColor(UltiDraw.LightGrey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField("Frames: " + Target.Data.GetTotalFrames(), GUILayout.Width(100f)); EditorGUILayout.LabelField("Time: " + Target.Data.GetTotalTime().ToString("F3") + "s", GUILayout.Width(100f)); EditorGUILayout.LabelField("Framerate: " + Target.Data.Framerate.ToString("F1") + "Hz", GUILayout.Width(130f)); EditorGUILayout.LabelField("Timescale:", GUILayout.Width(65f), GUILayout.Height(20f)); Target.Timescale = EditorGUILayout.FloatField(Target.Timescale, GUILayout.Width(30f), GUILayout.Height(20f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (Target.Playing) { if (Utility.GUIButton("||", Color.red, Color.black, 20f, 20f)) { Target.StopAnimation(); } } else { if (Utility.GUIButton("|>", Color.green, Color.black, 20f, 20f)) { Target.PlayAnimation(); } } if (Utility.GUIButton("<", UltiDraw.Grey, UltiDraw.White, 20f, 20f)) { Target.LoadPreviousFrame(); } if (Utility.GUIButton(">", UltiDraw.Grey, UltiDraw.White, 20f, 20f)) { Target.LoadNextFrame(); } int index = EditorGUILayout.IntSlider(frame.Index, 1, Target.Data.GetTotalFrames(), GUILayout.Width(440f)); if (index != frame.Index) { Target.LoadFrame(index); } EditorGUILayout.LabelField(frame.Timestamp.ToString("F3") + "s", Utility.GetFontColor(Color.white), GUILayout.Width(50f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (Utility.GUIButton("Mirror", Target.Mirror ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.SetMirror(!Target.Mirror); } EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton("Motion", Target.ShowMotion ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowMotion = !Target.ShowMotion; } if (Utility.GUIButton("Trajectory", Target.ShowTrajectory ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowTrajectory = !Target.ShowTrajectory; } if (Utility.GUIButton("Velocities", Target.ShowVelocities ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowVelocities = !Target.ShowVelocities; } if (Utility.GUIButton("Height Map", Target.ShowHeightMap ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowHeightMap = !Target.ShowHeightMap; } if (Utility.GUIButton("Depth Map", Target.ShowDepthMap ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowDepthMap = !Target.ShowDepthMap; } if (Utility.GUIButton("Depth Image", Target.ShowDepthImage ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowDepthImage = !Target.ShowDepthImage; } EditorGUILayout.EndHorizontal(); Utility.SetGUIColor(UltiDraw.Grey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.Mustard); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Target.InspectCamera = EditorGUILayout.Toggle("Camera", Target.InspectCamera); } if (Target.InspectCamera) { if (Utility.GUIButton("Auto Focus", Target.AutoFocus ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.SetAutoFocus(!Target.AutoFocus); } Target.FocusHeight = EditorGUILayout.FloatField("Focus Height", Target.FocusHeight); Target.FocusOffset = EditorGUILayout.FloatField("Focus Offset", Target.FocusOffset); Target.FocusDistance = EditorGUILayout.FloatField("Focus Distance", Target.FocusDistance); Target.FocusAngle = EditorGUILayout.Slider("Focus Angle", Target.FocusAngle, 0f, 360f); Target.FocusSmoothing = EditorGUILayout.Slider("Focus Smoothing", Target.FocusSmoothing, 0f, 1f); } } Utility.SetGUIColor(UltiDraw.Grey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.Mustard); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Target.InspectFrame = EditorGUILayout.Toggle("Frame", Target.InspectFrame); } if (Target.InspectFrame) { Color[] colors = UltiDraw.GetRainbowColors(Target.Data.Styles.Length); for (int i = 0; i < Target.Data.Styles.Length; i++) { float height = 25f; EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton(Target.Data.Styles[i], !frame.StyleFlags[i] ? colors[i].Transparent(0.25f) : colors[i], UltiDraw.White, 200f, height)) { frame.ToggleStyle(i); } Rect c = EditorGUILayout.GetControlRect(); Rect r = new Rect(c.x, c.y, frame.StyleValues[i] * c.width, height); EditorGUI.DrawRect(r, colors[i].Transparent(0.75f)); EditorGUILayout.FloatField(frame.StyleValues[i], GUILayout.Width(50f)); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton("<", UltiDraw.DarkGrey, UltiDraw.White, 25f, 50f)) { MotionData.Frame previous = frame.GetAnyPreviousStyleKey(); Target.LoadFrame(previous == null ? 0f : previous.Timestamp); } EditorGUILayout.BeginVertical(GUILayout.Height(50f)); Rect ctrl = EditorGUILayout.GetControlRect(); Rect rect = new Rect(ctrl.x, ctrl.y, ctrl.width, 50f); EditorGUI.DrawRect(rect, UltiDraw.Black); UltiDraw.Begin(); //Sequences for (int i = 0; i < Target.Data.Sequences.Length; i++) { float start = rect.x + (float)(Target.Data.Sequences[i].Start - 1) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width; float end = rect.x + (float)(Target.Data.Sequences[i].End - 1) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width; Vector3 a = new Vector3(start, rect.y, 0f); Vector3 b = new Vector3(end, rect.y, 0f); Vector3 c = new Vector3(start, rect.y + rect.height, 0f); Vector3 d = new Vector3(end, rect.y + rect.height, 0f); UltiDraw.DrawTriangle(a, c, b, UltiDraw.Yellow.Transparent(0.25f)); UltiDraw.DrawTriangle(b, c, d, UltiDraw.Yellow.Transparent(0.25f)); } //Styles for (int i = 0; i < Target.Data.Styles.Length; i++) { int x = 0; for (int j = 1; j < Target.Data.GetTotalFrames(); j++) { float val = Target.Data.Frames[j].StyleValues[i]; if ( Target.Data.Frames[x].StyleValues[i] < 1f && val == 1f || Target.Data.Frames[x].StyleValues[i] > 0f && val == 0f ) { float xStart = rect.x + (float)(Mathf.Max(x - 1, 0)) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width; float xEnd = rect.x + (float)j / (float)(Target.Data.GetTotalFrames() - 1) * rect.width; float yStart = rect.y + (1f - Target.Data.Frames[Mathf.Max(x - 1, 0)].StyleValues[i]) * rect.height; float yEnd = rect.y + (1f - Target.Data.Frames[j].StyleValues[i]) * rect.height; UltiDraw.DrawLine(new Vector3(xStart, yStart, 0f), new Vector3(xEnd, yEnd, 0f), colors[i]); x = j; } if ( Target.Data.Frames[x].StyleValues[i] == 0f && val > 0f || Target.Data.Frames[x].StyleValues[i] == 1f && val < 1f ) { float xStart = rect.x + (float)(x) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width; float xEnd = rect.x + (float)(j - 1) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width; float yStart = rect.y + (1f - Target.Data.Frames[x].StyleValues[i]) * rect.height; float yEnd = rect.y + (1f - Target.Data.Frames[j - 1].StyleValues[i]) * rect.height; UltiDraw.DrawLine(new Vector3(xStart, yStart, 0f), new Vector3(xEnd, yEnd, 0f), colors[i]); x = j; } if (j == Target.Data.GetTotalFrames() - 1) { float xStart = rect.x + (float)x / (float)(Target.Data.GetTotalFrames() - 1) * rect.width; float xEnd = rect.x + (float)(j - 1) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width; float yStart = rect.y + (1f - Target.Data.Frames[x].StyleValues[i]) * rect.height; float yEnd = rect.y + (1f - Target.Data.Frames[j - 1].StyleValues[i]) * rect.height; UltiDraw.DrawLine(new Vector3(xStart, yStart, 0f), new Vector3(xEnd, yEnd, 0f), colors[i]); x = j; } } } float pivot = rect.x + (float)(frame.Index - 1) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width; UltiDraw.DrawLine(new Vector3(pivot, rect.y, 0f), new Vector3(pivot, rect.y + rect.height, 0f), UltiDraw.White); UltiDraw.DrawWireCircle(new Vector3(pivot, rect.y, 0f), 8f, UltiDraw.Green); UltiDraw.DrawWireCircle(new Vector3(pivot, rect.y + rect.height, 0f), 8f, UltiDraw.Green); UltiDraw.End(); EditorGUILayout.EndVertical(); if (Utility.GUIButton(">", UltiDraw.DarkGrey, UltiDraw.White, 25f, 50f)) { MotionData.Frame next = frame.GetAnyNextStyleKey(); Target.LoadFrame(next == null ? Target.Data.GetTotalTime() : next.Timestamp); } EditorGUILayout.EndHorizontal(); } } Utility.SetGUIColor(UltiDraw.Grey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.Mustard); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Target.InspectExport = EditorGUILayout.Toggle("Export", Target.InspectExport); } if (Target.InspectExport) { for (int i = 0; i < Target.Data.Sequences.Length; i++) { Utility.SetGUIColor(UltiDraw.LightGrey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (Utility.GUIButton("Auto", UltiDraw.DarkGrey, UltiDraw.White, 80f, 16f)) { Target.Data.Sequences[i].AutoInterval(); } EditorGUILayout.LabelField("Start", GUILayout.Width(50f)); Target.Data.Sequences[i].SetStart(EditorGUILayout.IntField(Target.Data.Sequences[i].Start, GUILayout.Width(100f))); EditorGUILayout.LabelField("End", GUILayout.Width(50f)); Target.Data.Sequences[i].SetEnd(EditorGUILayout.IntField(Target.Data.Sequences[i].End, GUILayout.Width(100f))); //EditorGUILayout.LabelField("Export", GUILayout.Width(50f)); //Target.Data.Sequences[i].Export = EditorGUILayout.IntField(Target.Data.Sequences[i].Export, GUILayout.Width(100f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); for (int s = 0; s < Target.Data.Styles.Length; s++) { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField(Target.Data.Styles[s], GUILayout.Width(50f)); EditorGUILayout.LabelField("Style Copies", GUILayout.Width(100f)); Target.Data.Sequences[i].SetStyleCopies(s, EditorGUILayout.IntField(Target.Data.Sequences[i].StyleCopies[s], GUILayout.Width(100f))); EditorGUILayout.LabelField("Transition Copies", GUILayout.Width(100f)); Target.Data.Sequences[i].SetTransitionCopies(s, EditorGUILayout.IntField(Target.Data.Sequences[i].TransitionCopies[s], GUILayout.Width(100f))); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } for (int c = 0; c < Target.Data.Sequences[i].Copies.Length; c++) { EditorGUILayout.LabelField("Copy " + (c + 1) + " - " + "Start: " + Target.Data.Sequences[i].Copies[c].Start + " End: " + Target.Data.Sequences[i].Copies[c].End); } } } EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton("Add", UltiDraw.DarkGrey, UltiDraw.White)) { Target.Data.AddSequence(1, Target.Data.GetTotalFrames()); } if (Utility.GUIButton("Remove", UltiDraw.DarkGrey, UltiDraw.White)) { Target.Data.RemoveSequence(); } EditorGUILayout.EndHorizontal(); } } Utility.SetGUIColor(UltiDraw.Grey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.Mustard); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Target.InspectSettings = EditorGUILayout.Toggle("Settings", Target.InspectSettings); } if (Target.InspectSettings) { string[] presets = new string[4] { "Select preset...", "Dan", "Dog", "Interaction" }; switch (EditorGUILayout.Popup(0, presets)) { case 0: break; case 1: Target.Data.DepthMapAxis = MotionData.Axis.ZPositive; Target.Data.SetUnitScale(10f); Target.Data.MirrorAxis = MotionData.Axis.XPositive; for (int i = 0; i < Target.Data.Corrections.Length; i++) { Target.Data.SetCorrection(i, Vector3.zero); } Target.Data.ClearStyles(); Target.Data.AddStyle("Idle"); Target.Data.AddStyle("Walk"); Target.Data.AddStyle("Run"); Target.Data.AddStyle("Jump"); Target.Data.AddStyle("Crouch"); break; case 2: Target.Data.DepthMapAxis = MotionData.Axis.XPositive; Target.Data.SetUnitScale(100f); Target.Data.MirrorAxis = MotionData.Axis.ZPositive; for (int i = 0; i < Target.Data.Corrections.Length; i++) { if (i == 4 || i == 5 || i == 6 || i == 11) { Target.Data.SetCorrection(i, new Vector3(90f, 90f, 90f)); } else if (i == 24) { Target.Data.SetCorrection(i, new Vector3(-45f, 0f, 0f)); } else { Target.Data.SetCorrection(i, new Vector3(0f, 0f, 0f)); } } Target.Data.ClearStyles(); Target.Data.AddStyle("Idle"); Target.Data.AddStyle("Walk"); Target.Data.AddStyle("Pace"); Target.Data.AddStyle("Trot"); Target.Data.AddStyle("Canter"); Target.Data.AddStyle("Jump"); Target.Data.AddStyle("Sit"); Target.Data.AddStyle("Stand"); Target.Data.AddStyle("Lie"); break; case 3: Target.Data.DepthMapAxis = MotionData.Axis.ZPositive; Target.Data.SetUnitScale(100f); Target.Data.MirrorAxis = MotionData.Axis.XPositive; for (int i = 0; i < Target.Data.Corrections.Length; i++) { Target.Data.SetCorrection(i, Vector3.zero); } Target.Data.ClearStyles(); Target.Data.AddStyle("Idle"); Target.Data.AddStyle("Walk"); Target.Data.AddStyle("Run"); Target.Data.AddStyle("Jump"); Target.Data.AddStyle("Crouch"); Target.Data.AddStyle("Sit"); break; } Utility.SetGUIColor(UltiDraw.LightGrey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); if (Utility.GUIButton("Create Skeleton", UltiDraw.DarkGrey, UltiDraw.White)) { Target.CreateSkeleton(); } } Utility.SetGUIColor(UltiDraw.LightGrey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.LabelField("General"); Target.Data.SetUnitScale(EditorGUILayout.FloatField("Unit Scale", Target.Data.UnitScale)); Target.Data.MotionSmoothing = EditorGUILayout.IntField("Motion Smoothing", Target.Data.MotionSmoothing); Target.Data.GroundMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Ground Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Target.Data.GroundMask), InternalEditorUtility.layers)); Target.Data.ObjectMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Object Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Target.Data.ObjectMask), InternalEditorUtility.layers)); string[] names = new string[Target.Data.Source.Bones.Length]; for (int i = 0; i < Target.Data.Source.Bones.Length; i++) { names[i] = Target.Data.Source.Bones[i].Name; } Target.Data.HeightMapSensor = EditorGUILayout.Popup("Height Map Sensor", Target.Data.HeightMapSensor, names); Target.Data.HeightMapSize = EditorGUILayout.Slider("Height Map Size", Target.Data.HeightMapSize, 0f, 1f); Target.Data.DepthMapSensor = EditorGUILayout.Popup("Depth Map Sensor", Target.Data.DepthMapSensor, names); Target.Data.DepthMapAxis = (MotionData.Axis)EditorGUILayout.EnumPopup("Depth Map Axis", Target.Data.DepthMapAxis); Target.Data.DepthMapResolution = EditorGUILayout.IntField("Depth Map Resolution", Target.Data.DepthMapResolution); Target.Data.DepthMapSize = EditorGUILayout.FloatField("Depth Map Size", Target.Data.DepthMapSize); Target.Data.DepthMapDistance = EditorGUILayout.FloatField("Depth Map Distance", Target.Data.DepthMapDistance); Target.Data.SetStyleTransition(EditorGUILayout.Slider("Style Transition", Target.Data.StyleTransition, 0.1f, 1f)); for (int i = 0; i < Target.Data.Styles.Length; i++) { EditorGUILayout.BeginHorizontal(); Target.Data.Styles[i] = EditorGUILayout.TextField("Style " + (i + 1), Target.Data.Styles[i]); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton("Add Style", UltiDraw.DarkGrey, UltiDraw.White)) { Target.Data.AddStyle("Style"); } if (Utility.GUIButton("Remove Style", UltiDraw.DarkGrey, UltiDraw.White)) { Target.Data.RemoveStyle(); } EditorGUILayout.EndHorizontal(); } Utility.SetGUIColor(UltiDraw.LightGrey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.LabelField("Mirroring"); Target.Data.MirrorAxis = (MotionData.Axis)EditorGUILayout.EnumPopup("Axis", Target.Data.MirrorAxis); string[] names = new string[Target.Data.Source.Bones.Length]; for (int i = 0; i < Target.Data.Source.Bones.Length; i++) { names[i] = Target.Data.Source.Bones[i].Name; } for (int i = 0; i < Target.Data.Source.Bones.Length; i++) { EditorGUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.TextField(names[i]); EditorGUI.EndDisabledGroup(); Target.Data.SetSymmetry(i, EditorGUILayout.Popup(Target.Data.Symmetry[i], names)); Target.Data.SetCorrection(i, EditorGUILayout.Vector3Field("", Target.Data.Corrections[i])); EditorGUILayout.EndHorizontal(); } } } } Utility.SetGUIColor(UltiDraw.Mustard); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); if (Utility.GUIButton("Unload", UltiDraw.DarkGrey, UltiDraw.White)) { Target.UnloadFile(); } } } } }
public void Inspector() { Utility.SetGUIColor(UltiDraw.Grey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.DarkGrey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.Cyan); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.BeginHorizontal(); Target.Folder = EditorGUILayout.TextField("Folder", "Assets/" + Target.Folder.Substring(Mathf.Min(7, Target.Folder.Length))); if (Utility.GUIButton("Import", UltiDraw.DarkGrey, UltiDraw.White)) { Target.Import(); } EditorGUILayout.EndHorizontal(); Utility.SetGUIColor(Target.GetActor() == null ? UltiDraw.DarkRed : UltiDraw.White); Target.Actor = (Actor)EditorGUILayout.ObjectField("Actor", Target.GetActor(), typeof(Actor), true); Utility.ResetGUIColor(); EditorGUILayout.ObjectField("Environment", Target.GetEnvironment(), typeof(Transform), true); EditorGUILayout.BeginHorizontal(); string[] names = new string[Target.Files.Length]; if (names.Length == 0) { Target.LoadFile(EditorGUILayout.Popup("Data " + "(" + names.Length + ")", -1, names)); } else { for (int i = 0; i < names.Length; i++) { names[i] = Target.Files[i].name; } Target.LoadFile(EditorGUILayout.Popup("Data " + "(" + names.Length + ")", Target.ID, names)); } EditorGUILayout.EndHorizontal(); Target.LoadFile(EditorGUILayout.IntSlider(Target.ID, 0, Target.Files.Length - 1)); EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton("<", UltiDraw.Grey, UltiDraw.White)) { Target.LoadPreviousFile(); } if (Utility.GUIButton(">", UltiDraw.Grey, UltiDraw.White)) { Target.LoadNextFile(); } EditorGUILayout.EndHorizontal(); /* * if(GUILayout.Button("Import", GUILayout.Width(50f))) { * string folder = EditorUtility.OpenFolderPanel("Motion Editor", Application.dataPath, ""); * GUI.SetNextControlName(""); * GUI.FocusControl(""); * int pivot = folder.IndexOf("Assets"); * if(pivot >= 0) { * folder = folder.Substring(pivot); * if(AssetDatabase.IsValidFolder(folder)) { * Target.Import(folder); * } * } * GUIUtility.ExitGUI(); * } */ /* * if(GUILayout.Button("-", GUILayout.Width(18f))) { * Target.RemoveData(); * } * if(GUILayout.Button("R", GUILayout.Width(18f))) { * Target.RefreshData(); * } */ //EditorGUILayout.EndHorizontal(); } Utility.SetGUIColor(UltiDraw.Grey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.Cyan); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.LabelField("Camera"); } if (Utility.GUIButton("Auto Focus", Target.AutoFocus ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.SetAutoFocus(!Target.AutoFocus); } Target.FocusHeight = EditorGUILayout.FloatField("Focus Height", Target.FocusHeight); Target.FocusOffset = EditorGUILayout.FloatField("Focus Offset", Target.FocusOffset); Target.FocusDistance = EditorGUILayout.FloatField("Focus Distance", Target.FocusDistance); Target.FocusAngle = EditorGUILayout.Slider("Focus Angle", Target.FocusAngle, 0f, 360f); Target.FocusSmoothing = EditorGUILayout.Slider("Focus Smoothing", Target.FocusSmoothing, 0f, 1f); } if (Target.GetData() != null) { MotionData.Frame frame = Target.GetData().GetFrame(Target.Timestamp); Utility.SetGUIColor(UltiDraw.Mustard); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField("Frames: " + Target.GetData().GetTotalFrames(), GUILayout.Width(100f)); EditorGUILayout.LabelField("Time: " + Target.GetData().GetTotalTime().ToString("F3") + "s", GUILayout.Width(100f)); EditorGUILayout.LabelField("Framerate: " + Target.GetData().Framerate.ToString("F1") + "Hz", GUILayout.Width(130f)); EditorGUILayout.LabelField("Timescale:", GUILayout.Width(65f), GUILayout.Height(20f)); Target.Timescale = EditorGUILayout.FloatField(Target.Timescale, GUILayout.Width(30f), GUILayout.Height(20f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (Target.Playing) { if (Utility.GUIButton("||", Color.red, Color.black, 20f, 20f)) { Target.StopAnimation(); } } else { if (Utility.GUIButton("|>", Color.green, Color.black, 20f, 20f)) { Target.PlayAnimation(); } } if (Utility.GUIButton("<", UltiDraw.Grey, UltiDraw.White, 20f, 20f)) { Target.LoadPreviousFrame(); } if (Utility.GUIButton(">", UltiDraw.Grey, UltiDraw.White, 20f, 20f)) { Target.LoadNextFrame(); } int index = EditorGUILayout.IntSlider(frame.Index, 1, Target.GetData().GetTotalFrames(), GUILayout.Width(440f)); if (index != frame.Index) { Target.LoadFrame(index); } EditorGUILayout.LabelField(frame.Timestamp.ToString("F3") + "s", Utility.GetFontColor(Color.white), GUILayout.Width(50f)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (Utility.GUIButton("Mirror", Target.Mirror ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.SetMirror(!Target.Mirror); } EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton("Motion", Target.ShowMotion ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowMotion = !Target.ShowMotion; } if (Utility.GUIButton("Trajectory", Target.ShowTrajectory ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowTrajectory = !Target.ShowTrajectory; } if (Utility.GUIButton("Velocities", Target.ShowVelocities ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowVelocities = !Target.ShowVelocities; } if (Utility.GUIButton("Height Map", Target.ShowHeightMap ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowHeightMap = !Target.ShowHeightMap; } if (Utility.GUIButton("Depth Map", Target.ShowDepthMap ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowDepthMap = !Target.ShowDepthMap; } if (Utility.GUIButton("Depth Image", Target.ShowDepthImage ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black)) { Target.ShowDepthImage = !Target.ShowDepthImage; } EditorGUILayout.EndHorizontal(); Utility.SetGUIColor(UltiDraw.Grey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Utility.SetGUIColor(UltiDraw.Mustard); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Target.InspectFrame = EditorGUILayout.Toggle("Frame", Target.InspectFrame); } if (Target.InspectFrame) { Color[] colors = UltiDraw.GetRainbowColors(Target.GetData().Styles.Length); for (int i = 0; i < Target.GetData().Styles.Length; i++) { float height = 25f; EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton(Target.GetData().Styles[i], !frame.StyleFlags[i] ? colors[i].Transparent(0.25f) : colors[i], UltiDraw.White, 200f, height)) { frame.ToggleStyle(i); } Rect c = EditorGUILayout.GetControlRect(); Rect r = new Rect(c.x, c.y, frame.StyleValues[i] * c.width, height); EditorGUI.DrawRect(r, colors[i].Transparent(0.75f)); EditorGUILayout.FloatField(frame.StyleValues[i], GUILayout.Width(50f)); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton("<", UltiDraw.DarkGrey, UltiDraw.White, 25f, 50f)) { MotionData.Frame previous = frame.GetAnyPreviousStyleKey(); Target.LoadFrame(previous == null ? 0f : previous.Timestamp); } EditorGUILayout.BeginVertical(GUILayout.Height(50f)); Rect ctrl = EditorGUILayout.GetControlRect(); Rect rect = new Rect(ctrl.x, ctrl.y, ctrl.width, 50f); EditorGUI.DrawRect(rect, UltiDraw.Black); UltiDraw.Begin(); //Sequences for (int i = 0; i < Target.GetData().Sequences.Length; i++) { float start = rect.x + (float)(Target.GetData().Sequences[i].Start - 1) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width; float end = rect.x + (float)(Target.GetData().Sequences[i].End - 1) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width; Vector3 a = new Vector3(start, rect.y, 0f); Vector3 b = new Vector3(end, rect.y, 0f); Vector3 c = new Vector3(start, rect.y + rect.height, 0f); Vector3 d = new Vector3(end, rect.y + rect.height, 0f); UltiDraw.DrawTriangle(a, c, b, UltiDraw.Yellow.Transparent(0.25f)); UltiDraw.DrawTriangle(b, c, d, UltiDraw.Yellow.Transparent(0.25f)); } //Styles for (int i = 0; i < Target.GetData().Styles.Length; i++) { int x = 0; for (int j = 1; j < Target.GetData().GetTotalFrames(); j++) { float val = Target.GetData().Frames[j].StyleValues[i]; if ( Target.GetData().Frames[x].StyleValues[i] < 1f && val == 1f || Target.GetData().Frames[x].StyleValues[i] > 0f && val == 0f ) { float xStart = rect.x + (float)(Mathf.Max(x - 1, 0)) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width; float xEnd = rect.x + (float)j / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width; float yStart = rect.y + (1f - Target.GetData().Frames[Mathf.Max(x - 1, 0)].StyleValues[i]) * rect.height; float yEnd = rect.y + (1f - Target.GetData().Frames[j].StyleValues[i]) * rect.height; UltiDraw.DrawLine(new Vector3(xStart, yStart, 0f), new Vector3(xEnd, yEnd, 0f), colors[i]); x = j; } if ( Target.GetData().Frames[x].StyleValues[i] == 0f && val > 0f || Target.GetData().Frames[x].StyleValues[i] == 1f && val < 1f ) { float xStart = rect.x + (float)(x) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width; float xEnd = rect.x + (float)(j - 1) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width; float yStart = rect.y + (1f - Target.GetData().Frames[x].StyleValues[i]) * rect.height; float yEnd = rect.y + (1f - Target.GetData().Frames[j - 1].StyleValues[i]) * rect.height; UltiDraw.DrawLine(new Vector3(xStart, yStart, 0f), new Vector3(xEnd, yEnd, 0f), colors[i]); x = j; } if (j == Target.GetData().GetTotalFrames() - 1) { float xStart = rect.x + (float)x / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width; float xEnd = rect.x + (float)(j - 1) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width; float yStart = rect.y + (1f - Target.GetData().Frames[x].StyleValues[i]) * rect.height; float yEnd = rect.y + (1f - Target.GetData().Frames[j - 1].StyleValues[i]) * rect.height; UltiDraw.DrawLine(new Vector3(xStart, yStart, 0f), new Vector3(xEnd, yEnd, 0f), colors[i]); x = j; } } } float pivot = rect.x + (float)(frame.Index - 1) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width; UltiDraw.DrawLine(new Vector3(pivot, rect.y, 0f), new Vector3(pivot, rect.y + rect.height, 0f), UltiDraw.White); UltiDraw.DrawWireCircle(new Vector3(pivot, rect.y, 0f), 8f, UltiDraw.Green); UltiDraw.DrawWireCircle(new Vector3(pivot, rect.y + rect.height, 0f), 8f, UltiDraw.Green); UltiDraw.End(); EditorGUILayout.EndVertical(); if (Utility.GUIButton(">", UltiDraw.DarkGrey, UltiDraw.White, 25f, 50f)) { MotionData.Frame next = frame.GetAnyNextStyleKey(); Target.LoadFrame(next == null ? Target.GetData().GetTotalTime() : next.Timestamp); } EditorGUILayout.EndHorizontal(); } Utility.SetGUIColor(UltiDraw.Mustard); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Target.InspectExport = EditorGUILayout.Toggle("Export", Target.InspectExport); } if (Target.InspectExport) { for (int i = 0; i < Target.GetData().Sequences.Length; i++) { Utility.SetGUIColor(UltiDraw.LightGrey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (Utility.GUIButton("X", Color.cyan, Color.black, 15f, 15f)) { Target.GetData().Sequences[i].SetStart(Target.GetState().Index); } EditorGUILayout.LabelField("Start", GUILayout.Width(50f)); Target.GetData().Sequences[i].SetStart(EditorGUILayout.IntField(Target.GetData().Sequences[i].Start, GUILayout.Width(100f))); EditorGUILayout.LabelField("End", GUILayout.Width(50f)); Target.GetData().Sequences[i].SetEnd(EditorGUILayout.IntField(Target.GetData().Sequences[i].End, GUILayout.Width(100f))); if (Utility.GUIButton("X", Color.cyan, Color.black, 15f, 15f)) { Target.GetData().Sequences[i].SetEnd(Target.GetState().Index); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); for (int s = 0; s < Target.GetData().Styles.Length; s++) { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField(Target.GetData().Styles[s], GUILayout.Width(50f)); EditorGUILayout.LabelField("Style Copies", GUILayout.Width(100f)); Target.GetData().Sequences[i].SetStyleCopies(s, EditorGUILayout.IntField(Target.GetData().Sequences[i].StyleCopies[s], GUILayout.Width(100f))); EditorGUILayout.LabelField("Transition Copies", GUILayout.Width(100f)); Target.GetData().Sequences[i].SetTransitionCopies(s, EditorGUILayout.IntField(Target.GetData().Sequences[i].TransitionCopies[s], GUILayout.Width(100f))); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } //for(int c=0; c<Target.GetData().Sequences[i].Copies.Length; c++) { // EditorGUILayout.LabelField("Copy " + (c+1) + " - " + "Start: " + Target.GetData().Sequences[i].Copies[c].Start + " End: " + Target.GetData().Sequences[i].Copies[c].End); //} } } EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton("Add", UltiDraw.DarkGrey, UltiDraw.White)) { Target.GetData().AddSequence(1, Target.GetData().GetTotalFrames()); } if (Utility.GUIButton("Remove", UltiDraw.DarkGrey, UltiDraw.White)) { Target.GetData().RemoveSequence(); } EditorGUILayout.EndHorizontal(); } Utility.SetGUIColor(UltiDraw.Mustard); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); Target.InspectSettings = EditorGUILayout.Toggle("Settings", Target.InspectSettings); } if (Target.InspectSettings) { Utility.SetGUIColor(UltiDraw.LightGrey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); if (Utility.GUIButton("Create Skeleton", UltiDraw.DarkGrey, UltiDraw.White)) { Target.CreateSkeleton(); } } Utility.SetGUIColor(UltiDraw.LightGrey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.LabelField("General"); Target.GetData().Scaling = EditorGUILayout.FloatField("Scaling", Target.GetData().Scaling); Target.GetData().RootSmoothing = EditorGUILayout.IntField("Root Smoothing", Target.GetData().RootSmoothing); Target.GetData().GroundMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Ground Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Target.GetData().GroundMask), InternalEditorUtility.layers)); Target.GetData().ObjectMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Object Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Target.GetData().ObjectMask), InternalEditorUtility.layers)); string[] names = new string[Target.GetData().Source.Bones.Length]; for (int i = 0; i < Target.GetData().Source.Bones.Length; i++) { names[i] = Target.GetData().Source.Bones[i].Name; } Target.GetData().HeightMapSensor = EditorGUILayout.Popup("Height Map Sensor", Target.GetData().HeightMapSensor, names); Target.GetData().HeightMapSize = EditorGUILayout.Slider("Height Map Size", Target.GetData().HeightMapSize, 0f, 1f); Target.GetData().DepthMapSensor = EditorGUILayout.Popup("Depth Map Sensor", Target.GetData().DepthMapSensor, names); Target.GetData().DepthMapAxis = (MotionData.Axis)EditorGUILayout.EnumPopup("Depth Map Axis", Target.GetData().DepthMapAxis); Target.GetData().DepthMapResolution = EditorGUILayout.IntField("Depth Map Resolution", Target.GetData().DepthMapResolution); Target.GetData().DepthMapSize = EditorGUILayout.FloatField("Depth Map Size", Target.GetData().DepthMapSize); Target.GetData().DepthMapDistance = EditorGUILayout.FloatField("Depth Map Distance", Target.GetData().DepthMapDistance); Target.GetData().SetStyleTransition(EditorGUILayout.Slider("Style Transition", Target.GetData().StyleTransition, 0.1f, 1f)); for (int i = 0; i < Target.GetData().Styles.Length; i++) { EditorGUILayout.BeginHorizontal(); Target.GetData().Styles[i] = EditorGUILayout.TextField("Style " + (i + 1), Target.GetData().Styles[i]); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (Utility.GUIButton("Add Style", UltiDraw.DarkGrey, UltiDraw.White)) { Target.GetData().AddStyle("Style"); } if (Utility.GUIButton("Remove Style", UltiDraw.DarkGrey, UltiDraw.White)) { Target.GetData().RemoveStyle(); } EditorGUILayout.EndHorizontal(); } Utility.SetGUIColor(UltiDraw.LightGrey); using (new EditorGUILayout.VerticalScope("Box")) { Utility.ResetGUIColor(); EditorGUILayout.LabelField("Geometry"); Target.GetData().MirrorAxis = (MotionData.Axis)EditorGUILayout.EnumPopup("Mirror Axis", Target.GetData().MirrorAxis); string[] names = new string[Target.GetData().Source.Bones.Length]; for (int i = 0; i < Target.GetData().Source.Bones.Length; i++) { names[i] = Target.GetData().Source.Bones[i].Name; } for (int i = 0; i < Target.GetData().Source.Bones.Length; i++) { EditorGUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.TextField(names[i]); EditorGUI.EndDisabledGroup(); Target.GetData().SetSymmetry(i, EditorGUILayout.Popup(Target.GetData().Symmetry[i], names)); EditorGUILayout.EndHorizontal(); } if (Utility.GUIButton("Detect Symmetry", UltiDraw.DarkGrey, UltiDraw.White)) { Target.GetData().DetectSymmetry(); } } } } } } } }