private void DrawPlugElement(Rect rect, int index, bool active, bool focus) { rect = VxlGUI.GetPaddedRect(rect, 1); float field_width = Mathf.Min(100f, (rect.width - VxlGUI.SM_SPACE) / 2f); //draw left label GUI.Label(VxlGUI.GetSandwichedRectX(rect, 0, field_width + VxlGUI.SM_SPACE), _plug_labels[index], GUI.skin.GetStyle("LeftListLabel")); //draw right int field EditorGUI.BeginChangeCheck(); int plug = Mathf.Max(EditorGUI.IntField(VxlGUI.GetRightElement(rect, 0, field_width), _plugs[index], GUI.skin.GetStyle("DarkNumberField")), -1); if ((EditorGUI.EndChangeCheck() || _plugs[index] != plug)) { if (target == null || plugs == null || plugs.Count != _plug_cnt) { return; } Undo.RecordObject(target, "Modify Plugs"); plugs[index] = plug; _update_mesh = true; _render_mesh = true; _repaint_menu = true; //dirty target object EditorUtility.SetDirty(target); } }
private void UpdateRects(Rect rect) { _rect_selected = VxlGUI.GetBelowElement(rect, 0, VxlGUI.MED_BAR); Rect rect_panel = VxlGUI.GetPaddedRect(VxlGUI.GetSandwichedRectY(rect, 0, VxlGUI.MED_BAR), VxlGUI.LRG_PAD); _rect_submodes = VxlGUI.GetAboveElement(VxlGUI.GetLeftElement(rect_panel, 0, VxlGUI.MED_BAR), 0, Mathf.Min(_modes.Length * 60, rect_panel.height)); _rect_content = VxlGUI.GetSandwichedRectX(rect_panel, VxlGUI.MED_BAR + (3 * VxlGUI.SM_SPACE), 0); }
public override void DrawGUI(Rect rect) { //update lists UpdateVertexList(); //update important layout elements UpdateRects(rect); //disable panel check EditorGUI.BeginDisabledGroup(target == null); //draw vertex build title VxlGUI.DrawRect(_rect_vertex_title, "DarkGradient"); GUI.Label(_rect_vertex_title, "Vertex Builds", GUI.skin.GetStyle("LeftLightHeader")); //draw vertex build list VxlGUI.DrawRect(_rect_vertex_scrollview, "DarkWhite"); _vertex_scroll = GUI.BeginScrollView(_rect_vertex_scrollview, _vertex_scroll, _rect_vertex_content); _vertexlist.DoList(_rect_vertex_content); GUI.EndScrollView(); //draw vertex build button panel float button_width = Mathf.Min(60f, _rect_vertex_panel.width / 2f); VxlGUI.DrawRect(_rect_vertex_panel, "DarkGradient"); //draw vertex add button if (GUI.Button(VxlGUI.GetRightElement(_rect_vertex_panel, 0, button_width), "Add", GUI.skin.GetStyle("LightButton"))) { AddVertexElement(); } //disable operation check EditorGUI.BeginDisabledGroup((_vertices.Count <= 0) || (selectlist.Count <= 0)); //draw vertex delete button if (GUI.Button(VxlGUI.GetLeftElement(_rect_vertex_panel, 0, button_width), "Delete", GUI.skin.GetStyle("LightButton"))) { DeleteSelectedVertex(); } EditorGUI.EndDisabledGroup(); //draw import panel VxlGUI.DrawRect(_rect_import, "DarkWhite"); Rect importpad_rect = VxlGUI.GetPaddedRect(_rect_import, VxlGUI.MED_PAD); Rect importrow_rect = VxlGUI.GetAboveElement(importpad_rect, 0, VxlGUI.MED_BAR); GUI.Label(importrow_rect, "Import Obj Vertex and Triangles", GUI.skin.GetStyle("LeftLrgDarkLabel")); importrow_rect = VxlGUI.GetAboveElement(importpad_rect, 1, VxlGUI.MED_BAR); float import_width = Mathf.Min(100f, (importrow_rect.width - VxlGUI.SM_SPACE) / 2f); _importmesh = (Mesh)EditorGUI.ObjectField( VxlGUI.GetSandwichedRectX(importrow_rect, 0, import_width + VxlGUI.SM_SPACE), _importmesh, typeof(Mesh), false ); EditorGUI.BeginDisabledGroup(_importmesh == null); if (GUI.Button(VxlGUI.GetRightElement(importrow_rect, 0, import_width), "Import", GUI.skin.GetStyle("DarkButton"))) { ImportVertexAndTriangle(); } EditorGUI.EndDisabledGroup(); EditorGUI.EndDisabledGroup(); }
private void UpdateLayoutRects(Rect rect) { Rect rect_left = VxlGUI.GetLeftColumn(rect, VxlGUI.MED_SPACE, 0.5f); float template_height = (2 * VxlGUI.SM_PAD) + (6 * VxlGUI.MED_BAR) + (5 * VxlGUI.MED_SPACE) + (3 * VxlGUI.LRG_SPACE); _rect_selectheader = VxlGUI.GetAboveElement(rect_left, 0, VxlGUI.MED_BAR); _rect_selectscroll = VxlGUI.GetSandwichedRectY(rect_left, VxlGUI.MED_BAR + VxlGUI.SM_SPACE, VxlGUI.SM_SPACE + template_height); _rect_select_content = VxlGUI.GetScrollViewRect(_cornerlist, _rect_selectscroll.width, _rect_selectscroll.height); Rect rect_right = VxlGUI.GetRightColumn(rect, VxlGUI.MED_SPACE, 0.5f); _rect_patheader = VxlGUI.GetAboveElement(rect_right, 0, VxlGUI.MED_BAR); _rect_patscroll = VxlGUI.GetSandwichedRectY(rect_right, VxlGUI.MED_BAR + VxlGUI.SM_SPACE, VxlGUI.SM_SPACE + VxlGUI.MED_BAR); _rect_patcontent = VxlGUI.GetScrollViewRect(_patternlist, _rect_patscroll.width, _rect_patscroll.height); _rect_patpanel = VxlGUI.GetBelowElement(rect_right, 0, VxlGUI.MED_BAR); _rect_temparea = VxlGUI.GetBelowElement(rect_left, 0, template_height); Rect rect_content = VxlGUI.GetPaddedRect(_rect_temparea, VxlGUI.SM_PAD, VxlGUI.MED_PAD); _rect_tempheader = VxlGUI.GetAboveElement(rect_content, 0, VxlGUI.MED_BAR, VxlGUI.MED_SPACE, 0); Rect rect_row = VxlGUI.GetAboveElement(rect_content, 1, VxlGUI.MED_BAR, VxlGUI.MED_SPACE, VxlGUI.LRG_SPACE); _rect_voxelid = VxlGUI.GetSandwichedRectX(rect_row, 0, (3 * VxlGUI.INTFIELD) + (2 * VxlGUI.SM_SPACE) + VxlGUI.MED_SPACE); _rect_d5 = VxlGUI.GetRightElement(rect_row, 2, VxlGUI.INTFIELD, VxlGUI.SM_SPACE, 0); _rect_d1 = VxlGUI.GetRightElement(rect_row, 1, VxlGUI.INTFIELD, VxlGUI.SM_SPACE, 0); _rect_d3 = VxlGUI.GetRightElement(rect_row, 0, VxlGUI.INTFIELD, VxlGUI.SM_SPACE, 0); rect_row = VxlGUI.GetAboveElement(rect_content, 2, VxlGUI.MED_BAR, VxlGUI.MED_SPACE, VxlGUI.LRG_SPACE); _rect_above = VxlGUI.GetSandwichedRectX(rect_row, 0, (3 * VxlGUI.INTFIELD) + (2 * VxlGUI.SM_SPACE) + VxlGUI.MED_SPACE); _rect_above_d5 = VxlGUI.GetRightElement(rect_row, 2, VxlGUI.INTFIELD, VxlGUI.SM_SPACE, 0); _rect_above_d1 = VxlGUI.GetRightElement(rect_row, 1, VxlGUI.INTFIELD, VxlGUI.SM_SPACE, 0); _rect_above_d3 = VxlGUI.GetRightElement(rect_row, 0, VxlGUI.INTFIELD, VxlGUI.SM_SPACE, 0); rect_row = VxlGUI.GetAboveElement(rect_content, 3, VxlGUI.MED_BAR, VxlGUI.MED_SPACE, VxlGUI.LRG_SPACE); _rect_below = VxlGUI.GetSandwichedRectX(rect_row, 0, (3 * VxlGUI.INTFIELD) + (2 * VxlGUI.SM_SPACE) + VxlGUI.MED_SPACE); _rect_below_d5 = VxlGUI.GetRightElement(rect_row, 2, VxlGUI.INTFIELD, VxlGUI.SM_SPACE, 0); _rect_below_d1 = VxlGUI.GetRightElement(rect_row, 1, VxlGUI.INTFIELD, VxlGUI.SM_SPACE, 0); _rect_below_d3 = VxlGUI.GetRightElement(rect_row, 0, VxlGUI.INTFIELD, VxlGUI.SM_SPACE, 0); rect_row = VxlGUI.GetAboveElement(rect_content, 4, VxlGUI.MED_BAR, VxlGUI.MED_SPACE, 2 * VxlGUI.LRG_SPACE); float quarter = rect_row.width / 4f; _rect_flipx = VxlGUI.GetSandwichedRectX(VxlGUI.GetLeftColumn(rect_row, 0, 0.5f), quarter - 20, 0); _rect_flipy = VxlGUI.GetSandwichedRectX(VxlGUI.GetRightColumn(rect_row, 0, 0.5f), quarter - 20, 0); rect_row = VxlGUI.GetAboveElement(rect_content, 5, VxlGUI.MED_BAR, VxlGUI.MED_SPACE, 3 * VxlGUI.LRG_SPACE); _rect_tempbutton = VxlGUI.GetRightElement(rect_row, 0, 80); }
private void DrawVertexElement(Rect rect, int index, bool active, bool focus) { EditorGUI.BeginChangeCheck(); float width = Mathf.Min(rect.width / 4f); //draw label EditorGUI.LabelField( VxlGUI.GetLeftElement(rect, 0, width), "Vertex " + index, GUI.skin.GetStyle("LeftListLabel") ); Vector3 vertex = EditorGUI.Vector3Field(VxlGUI.GetSandwichedRectX(rect, width, 0), "", _vertices[index]); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Updated Vertex"); target.vertices[index] = vertex; _repaint_menu = true; _render_mesh = true; _update_mesh = true; EditorUtility.SetDirty(target); } }
public override void DrawGUI(Rect rect) { float width = Mathf.Min(200, rect.width); rect = new Rect(rect.x, rect.y, width, rect.height); if (!expanded) { //calculate rect rect = VxlGUI.GetAboveElement(rect, 0, VxlGUI.MED_BAR); //draw background VxlGUI.DrawRect(rect, "DarkTransparentGrey"); //draw foldout toggle label EditorGUI.BeginChangeCheck(); expanded = EditorGUI.Foldout(rect, expanded, "Display", true, GUI.skin.GetStyle("LightBoldFoldout")); if (EditorGUI.EndChangeCheck()) { _repaint_menu = true; } } else { float content_height = GetPanelHeight(); float panel_height = Mathf.Min(rect.height, VxlGUI.SM_SPACE + VxlGUI.MED_BAR + content_height); float scroll_height = Mathf.Max(0, panel_height - VxlGUI.SM_SPACE - VxlGUI.MED_BAR); Rect panel_rect = VxlGUI.GetAboveElement(rect, 0, panel_height); Rect rect_scroll = VxlGUI.GetSandwichedRectY(panel_rect, VxlGUI.MED_BAR + VxlGUI.SM_SPACE, 0); Rect content_rect = VxlGUI.GetVerticalScrollViewRect(rect_scroll.width, rect_scroll.height, content_height); VxlGUI.DrawRect(panel_rect, "DarkTransparentGrey"); EditorGUI.BeginChangeCheck(); Rect row_rect = VxlGUI.GetAboveElement(panel_rect, 0, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0); expanded = EditorGUI.Foldout(row_rect, expanded, "Display", true, GUI.skin.GetStyle("LightBoldFoldout")); Rect rect_content = VxlGUI.GetBelowRightElement(content_rect, 0, content_rect.width - VxlGUI.MED_BAR, 0, content_rect.height); if (EditorGUI.EndChangeCheck()) { _repaint_menu = true; } EditorGUI.BeginChangeCheck(); _scroll = GUI.BeginScrollView(rect_scroll, _scroll, content_rect); //origin int level = 0; row_rect = VxlGUI.GetAboveElement(rect_content, level, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0); origin_enabled = EditorGUI.Foldout(row_rect, origin_enabled, "Origin", true, GUI.skin.GetStyle("LightFoldout")); level += 1; //global axis row_rect = VxlGUI.GetAboveElement(rect_content, level, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0); global_enabled = EditorGUI.Foldout(row_rect, global_enabled, "Global Axis", true, GUI.skin.GetStyle("LightFoldout")); level += 1; //axi row_rect = VxlGUI.GetAboveElement(rect_content, level, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0); voxelaxi_enabled = EditorGUI.Foldout(row_rect, voxelaxi_enabled, "Voxel Axi", true, GUI.skin.GetStyle("LightFoldout")); level += 1; //frame if (enable_voxelframe) { row_rect = VxlGUI.GetAboveElement(rect_content, level, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0); voxelframe_enabled = EditorGUI.Foldout(row_rect, voxelframe_enabled, "Voxel Frame", true, GUI.skin.GetStyle("LightFoldout")); level += 1; if (enable_voxelflip && voxelframe_enabled) { float y = (level * VxlGUI.MED_BAR) + ((Mathf.Max(0, level - 1) * VxlGUI.SM_SPACE)); Rect frame_rect = VxlGUI.GetSandwichedRectX(VxlGUI.GetSandwichedRectY(rect_content, y, 0), VxlGUI.MED_BAR, 0); row_rect = VxlGUI.GetAboveElement(frame_rect, 0, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0); voxelframe_flip = EditorGUI.Foldout(row_rect, voxelframe_flip, "Flip Voxel", true, GUI.skin.GetStyle("LightFoldout")); level += 1; } } GUI.EndScrollView(); if (EditorGUI.EndChangeCheck()) { _repaint_menu = true; _render_mesh = true; } } }