コード例 #1
0
    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);
        }
    }
コード例 #2
0
    private void DrawPatternElement(Rect rect, int index, bool active, bool focus)
    {
        Rect rect_content = VxlGUI.GetPaddedRect(rect, VxlGUI.MED_PAD);

        float two = rect_content.width / 2f;
        //row 0 - (4) (5) (0)
        Rect rect_row = VxlGUI.GetAboveElement(rect_content, 0, VxlGUI.SM_BAR);

        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Plugs:", GUI.skin.GetStyle("LeftLightHeader"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 2, two / 3f), _patterns[index].c4_p.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 1, two / 3f), _patterns[index].c5_p.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 0, two / 3f), _patterns[index].c0_p.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        //row 1 - (3) (2) (1)
        rect_row = VxlGUI.GetAboveElement(rect_content, 1, VxlGUI.SM_BAR);
        GUI.Label(VxlGUI.GetRightElement(rect_row, 2, two / 3f), _patterns[index].c3_p.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 1, two / 3f), _patterns[index].c2_p.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 0, two / 3f), _patterns[index].c1_p.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        //row 2 - above below
        rect_row = VxlGUI.GetAboveElement(rect_content, 2, VxlGUI.SM_BAR);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Voxels:", GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 1, two / 2f), _patterns[index].vb.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 0, two / 2f), _patterns[index].va.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        //row 3 - flipx flipy
        rect_row = VxlGUI.GetAboveElement(rect_content, 3, VxlGUI.SM_BAR);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two / 2f), "FlipX", GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 1, two / 2f), _patterns[index].xflip.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 2, two / 2f), "FlipY", GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 3, two / 2f), _patterns[index].yflip.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
    }
コード例 #3
0
    private void DrawPatternElement(Rect rect, int index, bool active, bool focus)
    {
        Rect rect_content = VxlGUI.GetPaddedRect(rect, VxlGUI.MED_PAD);

        float two = rect_content.width / 2f;
        //row 0 - a1 a0
        Rect rect_row = VxlGUI.GetAboveElement(rect_content, 0, VxlGUI.SM_BAR);

        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Above:", GUI.skin.GetStyle("LeftLightHeader"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 1, two / 2f), _patterns[index].a1_p.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 0, two / 2f), _patterns[index].a0_p.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        //row 1 - b1 b0
        rect_row = VxlGUI.GetAboveElement(rect_content, 1, VxlGUI.SM_BAR);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Below:", GUI.skin.GetStyle("LeftLightHeader"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 1, two / 2f), _patterns[index].b1_p.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 0, two / 2f), _patterns[index].b0_p.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        //row 2 - vin vout
        rect_row = VxlGUI.GetAboveElement(rect_content, 2, VxlGUI.SM_BAR);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Voxels:", GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 1, two / 2f), _patterns[index].vin.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 0, two / 2f), _patterns[index].vout.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        //row 3 - flipx flipy
        rect_row = VxlGUI.GetAboveElement(rect_content, 3, VxlGUI.SM_BAR);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two / 2f), "FlipX", GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 1, two / 2f), _patterns[index].xflip.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 2, two / 2f), "FlipY", GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 3, two / 2f), _patterns[index].yflip.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
    }
コード例 #4
0
    private void DrawPatternElement(Rect rect, int index, bool active, bool focus)
    {
        Rect  rect_content = VxlGUI.GetPaddedRect(rect, VxlGUI.MED_PAD);
        Rect  rect_row     = VxlGUI.GetAboveElement(rect_content, 0, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        float two          = rect_row.width / 2f;

        //plugs row
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Plugs:", GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 1, two / 2f), _patterns[index].p0.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 0, two / 2f), _patterns[index].p1.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        //above voxels
        rect_row = VxlGUI.GetAboveElement(rect_content, 1, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Above:", GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 1, two / 2f), _patterns[index].a0.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 0, two / 2f), _patterns[index].a1.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        //below voxels
        rect_row = VxlGUI.GetAboveElement(rect_content, 2, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Below:", GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 1, two / 2f), _patterns[index].b0.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetRightElement(rect_row, 0, two / 2f), _patterns[index].b1.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        //flips
        rect_row = VxlGUI.GetAboveElement(rect_content, 3, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two / 2f), "FlipX", GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 1, two / 2f), _patterns[index].xflip.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 2, two / 2f), "FlipY", GUI.skin.GetStyle("LeftDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 3, two / 2f), _patterns[index].yflip.ToString(), GUI.skin.GetStyle("LeftDarkLabel"));
    }
コード例 #5
0
    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);
    }
コード例 #6
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();
    }
コード例 #7
0
    public override void DrawPreview(Rect rect)
    {
        //update preview displays
        _selectdisplay.selected      = _preview.secondaryCount;
        _selectdisplay.superselected = _preview.secondarySuper;

        rect = VxlGUI.GetPaddedRect(rect, VxlGUI.MED_PAD);
        float width = Mathf.Min(200, rect.width / 2f);

        _selectdisplay.DrawGUI(VxlGUI.GetAboveRightElement(rect, 0, width, 0, rect.height / 2f));
    }
コード例 #8
0
    private void DrawTriangleElement(Rect rect, int index, bool active, bool focus)
    {
        rect = VxlGUI.GetPaddedRect(rect, VxlGUI.SM_SPACE);
        //draw indexed label
        GUI.Label(
            VxlGUI.GetAboveElement(rect, 0, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0),
            "Tri: " + index,
            GUI.skin.GetStyle("LeftListLabel")
            );
        EditorGUI.BeginChangeCheck();
        //draw triangle index 0
        TriIndex index0 = DrawTriangleEditElement(
            VxlGUI.GetAboveElement(rect, 1, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0),
            _triangles[index].type0,
            _triangles[index].vertex0
            );
        //draw triangle index 1
        TriIndex index1 = DrawTriangleEditElement(
            VxlGUI.GetAboveElement(rect, 2, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0),
            _triangles[index].type1,
            _triangles[index].vertex1
            );
        //draw triangle index 2
        TriIndex index2 = DrawTriangleEditElement(
            VxlGUI.GetAboveElement(rect, 3, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0),
            _triangles[index].type2,
            _triangles[index].vertex2
            );

        if (EditorGUI.EndChangeCheck())
        {
            if (target != null)
            {
                if (target == null || target.triangles == null)
                {
                    return;
                }
                if (index < 0 || index >= target.triangles.Count)
                {
                    return;
                }
                Undo.RecordObject(target, "Update Triangle Build");
                target.triangles[index] = new Triangle(index0, index1, index2);
                _update_mesh            = true;
                _render_mesh            = true;
                _repaint_menu           = true;
                //dirty target object
                EditorUtility.SetDirty(target);
            }
        }
    }
コード例 #9
0
    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);
    }
コード例 #10
0
 public override void DrawPreview(Rect rect)
 {
     //process preview controls
     ProcessPreviewInput(rect);
     //update display flags
     UpdateDisplayFlags();
     if (_update_mesh)
     {
         //update mesh
         UpdateMesh();
         //clear update mesh flag
         _update_mesh = false;
     }
     if (_render_mesh)
     {
         UpdateDisplay();
         //update preview render texture
         _previewutility.BeginPreview(rect, GUI.skin.GetStyle("DarkGrey"));
         //draw axi stuff
         _display.DrawDisplayObjects(_previewutility);
         //draw mesh
         if (_mesh.triangles.Length > 0 && mesh_mat != null)
         {
             _previewutility.DrawMesh(_mesh, Vector3.zero, Quaternion.identity, mesh_mat, 0);
         }
         //draw vertices
         DrawVertex();
         //render preview scene
         _previewutility.Render();
         _render = _previewutility.EndPreview();
         //clear render mesh flag
         _render_mesh = false;
     }
     //return if nothing to draw
     if (_render == null)
     {
         return;
     }
     //draw preview render texture
     GUI.DrawTexture(rect, _render);
     rect = VxlGUI.GetPaddedRect(rect, VxlGUI.MED_PAD);
     _display.DrawGUI(new Rect(rect.x, rect.y, 0.5f * rect.width, 0.5f * rect.height));
 }
コード例 #11
0
    private void DrawAddPatternPanel()
    {
        EditorGUI.BeginChangeCheck();
        VxlGUI.DrawRect(_rect_pattemplateheader, "DarkGradient");
        GUI.Label(_rect_pattemplateheader, "Add Rect Pattern", GUI.skin.GetStyle("LeftLightHeader"));
        VxlGUI.DrawRect(_rect_pattemplate, "DarkWhite");
        Rect rect_content = VxlGUI.GetPaddedRect(_rect_pattemplate, VxlGUI.MED_PAD);

        float two = rect_content.width / 2f;
        //row 0 - a1 a0
        Rect rect_row = VxlGUI.GetAboveElement(rect_content, 0, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);

        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Above:", GUI.skin.GetStyle("LeftLightHeader"));
        int c4 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 2, Mathf.Min(two / 3f, 40)), _addpat.c4_p);
        int c5 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 1, Mathf.Min(two / 3f, 40)), _addpat.c5_p);
        int c0 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 0, Mathf.Min(two / 3f, 40)), _addpat.c0_p);

        //row 1 - b1 b0
        rect_row = VxlGUI.GetAboveElement(rect_content, 1, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Below:", GUI.skin.GetStyle("LeftLightHeader"));
        int c3 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 2, Mathf.Min(two / 3f, 40)), _addpat.c3_p);
        int c2 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 1, Mathf.Min(two / 3f, 40)), _addpat.c2_p);
        int c1 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 0, Mathf.Min(two / 3f, 40)), _addpat.c1_p);

        //row 2 - vin vout
        rect_row = VxlGUI.GetAboveElement(rect_content, 2, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Voxels:", GUI.skin.GetStyle("LeftLightHeader"));
        int vb = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 1, Mathf.Min(two / 2f, 40)), _addpat.vb);
        int va = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 0, Mathf.Min(two / 2f, 40)), _addpat.va);

        //row 3 - flipx flipy
        rect_row = VxlGUI.GetAboveElement(rect_content, 3, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        bool flipx = EditorGUI.Foldout(VxlGUI.GetLeftElement(rect_row, 0, two), _addpat.xflip, "FlipX", true, GUI.skin.GetStyle("LightFoldout"));
        bool flipy = EditorGUI.Foldout(VxlGUI.GetLeftElement(rect_row, 1, two), _addpat.yflip, "FlipY", true, GUI.skin.GetStyle("LightFoldout"));

        //apply change
        if (EditorGUI.EndChangeCheck())
        {
            _addpat       = new HexagonPattern(flipx, flipy, c0, c1, c2, c3, c4, c5, va, vb);
            _repaint_menu = false;
        }
    }
コード例 #12
0
    private void DrawAddPatternPanel()
    {
        EditorGUI.BeginChangeCheck();
        VxlGUI.DrawRect(_rect_pattemplateheader, "DarkGradient");
        GUI.Label(_rect_pattemplateheader, "Add Rect Pattern", GUI.skin.GetStyle("LeftLightHeader"));
        VxlGUI.DrawRect(_rect_pattemplate, "DarkWhite");
        Rect rect_content = VxlGUI.GetPaddedRect(_rect_pattemplate, VxlGUI.MED_PAD);

        float two = rect_content.width / 2f;
        //row 0 - a1 a0
        Rect rect_row = VxlGUI.GetAboveElement(rect_content, 0, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);

        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Above:", GUI.skin.GetStyle("LeftLightHeader"));
        int a1 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 1, Mathf.Min(two / 2f, 40)), _addpat.a1_p);
        int a0 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 0, Mathf.Min(two / 2f, 40)), _addpat.a0_p);

        //row 1 - b1 b0
        rect_row = VxlGUI.GetAboveElement(rect_content, 1, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Below:", GUI.skin.GetStyle("LeftLightHeader"));
        int b1 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 1, Mathf.Min(two / 2f, 40)), _addpat.b1_p);
        int b0 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 0, Mathf.Min(two / 2f, 40)), _addpat.b0_p);

        //row 2 - vin vout
        rect_row = VxlGUI.GetAboveElement(rect_content, 2, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Voxels:", GUI.skin.GetStyle("LeftLightHeader"));
        int vin  = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 1, Mathf.Min(two / 2f, 40)), _addpat.vin);
        int vout = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 0, Mathf.Min(two / 2f, 40)), _addpat.vout);

        //row 3 - flipx flipy
        rect_row = VxlGUI.GetAboveElement(rect_content, 3, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        bool flipx = EditorGUI.Foldout(VxlGUI.GetLeftElement(rect_row, 0, two), _addpat.xflip, "FlipX", true, GUI.skin.GetStyle("LightFoldout"));
        bool flipy = EditorGUI.Foldout(VxlGUI.GetLeftElement(rect_row, 1, two), _addpat.yflip, "FlipY", true, GUI.skin.GetStyle("LightFoldout"));

        //apply change
        if (EditorGUI.EndChangeCheck())
        {
            _addpat       = new RectPattern(flipx, flipy, a0, b0, a1, b1, vin, vout);
            _repaint_menu = false;
        }
    }
コード例 #13
0
    private void DrawPatternElement(Rect rect, int index, bool active, bool focus)
    {
        Rect  rect_content = VxlGUI.GetPaddedRect(rect, VxlGUI.MED_PAD);
        Rect  rect_row     = VxlGUI.GetAboveElement(rect_content, 0, VxlGUI.SM_BAR);
        float width        = (rect_content.width / 3f) - (2 * VxlGUI.SM_SPACE);

        //row 0
        GUI.Label(rect_row, "Above IDs", GUI.skin.GetStyle("LeftDarkLabel"));
        //row 1
        rect_row = VxlGUI.GetAboveElement(rect_content, 1, VxlGUI.SM_BAR);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, width, VxlGUI.SM_SPACE, 0), _patterns[index].a0.ToString(), GUI.skin.GetStyle("RightDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 1, width, VxlGUI.SM_SPACE, 0), _patterns[index].a1.ToString(), GUI.skin.GetStyle("RightDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 2, width, VxlGUI.SM_SPACE, 0), _patterns[index].a2.ToString(), GUI.skin.GetStyle("RightDarkLabel"));
        //row 2
        rect_row = VxlGUI.GetAboveElement(rect_content, 2, VxlGUI.SM_BAR);
        GUI.Label(rect_row, "Below IDs", GUI.skin.GetStyle("LeftDarkLabel"));
        //row 3
        rect_row = VxlGUI.GetAboveElement(rect_content, 3, VxlGUI.SM_BAR);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, width, VxlGUI.SM_SPACE, 0), _patterns[index].b0.ToString(), GUI.skin.GetStyle("RightDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 1, width, VxlGUI.SM_SPACE, 0), _patterns[index].b1.ToString(), GUI.skin.GetStyle("RightDarkLabel"));
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 2, width, VxlGUI.SM_SPACE, 0), _patterns[index].b2.ToString(), GUI.skin.GetStyle("RightDarkLabel"));
    }
コード例 #14
0
    public override void DrawGUI(Rect rect)
    {
        UpdateRects(rect);

        //rename - do later
        EditorGUI.BeginDisabledGroup(selected == null);
        VxlGUI.DrawRect(_rect_rename, "LightBlack");
        EditorGUI.BeginChangeCheck();
        GUI.Label(VxlGUI.GetLeftColumn(_rect_rename, 0, 0.5f), "Rename:", GUI.skin.GetStyle("RightLightLabel"));
        string name = "";

        if (selected != null)
        {
            name = selected.objname;
        }
        name = EditorGUI.DelayedTextField(
            VxlGUI.GetPaddedRect(VxlGUI.GetRightColumn(_rect_rename, 0, 0.5f), VxlGUI.SM_PAD),
            name,
            GUI.skin.GetStyle("RightLightText")
            );
        if (EditorGUI.EndChangeCheck())
        {
            if (RenameSelectedUnsaved(name) || RenameSelectedAsset(name))
            {
                if (!_unsaved_selected)
                {
                    SetSelectedFromGUIDList();
                }
                RefreshAssets();
            }
        }
        EditorGUI.EndDisabledGroup();

        //guid list
        VxlGUI.DrawRect(_rect_guidheader, "DarkGradient");
        VxlGUI.DrawRect(_rect_guidfooter, "DarkGradient");
        VxlGUI.DrawRect(_rect_guidscroll, "DarkWhite");
        GUI.Label(_rect_guidheader, "Project Assets", GUI.skin.GetStyle("LeftLightHeader"));
        _scroll_guid = GUI.BeginScrollView(_rect_guidscroll, _scroll_guid, _rect_guidcontent);
        _guidlist.DoList(_rect_guidcontent);
        GUI.EndScrollView();
        float width = Mathf.Min(60f, _rect_guidfooter.width);

        if (GUI.Button(VxlGUI.GetRightElement(_rect_guidfooter, 0, width), "Refresh", GUI.skin.GetStyle("LightButton")))
        {
            RefreshAssets();
        }

        //unsaved list
        VxlGUI.DrawRect(_rect_unsavedheader, "DarkGradient");
        VxlGUI.DrawRect(_rect_unsavedfooter, "DarkGradient");
        VxlGUI.DrawRect(_rect_unsavedscroll, "DarkWhite");
        GUI.Label(_rect_unsavedheader, "Unsaved Objects", GUI.skin.GetStyle("LeftLightHeader"));
        _scroll_unsaved = GUI.BeginScrollView(_rect_unsavedscroll, _scroll_unsaved, _rect_unsavedcontent);
        if (_unsavedlist != null)
        {
            _unsavedlist.DoList(_rect_unsavedcontent);
        }
        GUI.EndScrollView();
        width = Mathf.Min(60f, _rect_unsavedfooter.width / 3f);
        if (GUI.Button(VxlGUI.GetRightElement(_rect_unsavedfooter, 0, width), "Add", GUI.skin.GetStyle("LightButton")))
        {
            AddUnsaved();
        }
        EditorGUI.BeginDisabledGroup(!_unsaved_selected || _index < 0 || _index >= _unsaveds.Count);
        if (GUI.Button(VxlGUI.GetRightElement(_rect_unsavedfooter, 1, width), "Save", GUI.skin.GetStyle("LightButton")))
        {
            SaveAsset();
            RefreshAssets();
            SetSelectedFromGUIDList();
        }
        if (GUI.Button(VxlGUI.GetLeftElement(_rect_unsavedfooter, 0, width), "Delete", GUI.skin.GetStyle("LightButton")))
        {
            DeleteUnsaved();
        }
        EditorGUI.EndDisabledGroup();
    }
コード例 #15
0
    public override void DrawGUI(Rect rect)
    {
        //update both visual lists
        UpdateEdgeList();
        UpdatePatternList();
        //update layout rects
        UpdateLayoutRects(rect);

        //draw key selection header
        VxlGUI.DrawRect(_rect_selectheader, "DarkGradient");
        GUI.Label(_rect_selectheader, _title, GUI.skin.GetStyle("LeftLightHeader"));
        //draw key selection list
        VxlGUI.DrawRect(_rect_selectscroll, "DarkWhite");
        _selectscroll = GUI.BeginScrollView(_rect_selectscroll, _selectscroll, _rect_select_content);
        _edgelist.DoList(_rect_select_content);
        GUI.EndScrollView();
        //draw add pattern template
        VxlGUI.DrawRect(_rect_pattemplateheader, "DarkGradient");
        GUI.Label(_rect_pattemplateheader, "Add Lateral Edge", GUI.skin.GetStyle("LeftLightHeader"));
        VxlGUI.DrawRect(_rect_pattemplate, "DarkWhite");
        Rect rect_content = VxlGUI.GetPaddedRect(_rect_pattemplate, VxlGUI.MED_PAD);

        EditorGUI.BeginChangeCheck();
        Rect rect_row = VxlGUI.GetAboveElement(rect_content, 0, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);

        float two = rect_row.width / 2f;

        //plugs row
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Plugs:", GUI.skin.GetStyle("LeftLrgDarkLabel"));
        int p0 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 1, Mathf.Min(two / 2f, 40)), _addpat.p0);
        int p1 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 0, Mathf.Min(two / 2f, 40)), _addpat.p1);

        //above voxels
        rect_row = VxlGUI.GetAboveElement(rect_content, 1, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Above:", GUI.skin.GetStyle("LeftLrgDarkLabel"));
        int a0 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 1, Mathf.Min(two / 2f, 40)), _addpat.a0);
        int a1 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 0, Mathf.Min(two / 2f, 40)), _addpat.a1);

        //below voxels
        rect_row = VxlGUI.GetAboveElement(rect_content, 2, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        GUI.Label(VxlGUI.GetLeftElement(rect_row, 0, two), "Below:", GUI.skin.GetStyle("LeftLrgDarkLabel"));
        int b0 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 1, Mathf.Min(two / 2f, 40)), _addpat.b0);
        int b1 = EditorGUI.IntField(VxlGUI.GetRightElement(rect_row, 0, Mathf.Min(two / 2f, 40)), _addpat.b1);

        //flips
        rect_row = VxlGUI.GetAboveElement(rect_content, 3, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
        bool flipx = EditorGUI.Foldout(VxlGUI.GetLeftElement(rect_row, 0, two), _addpat.xflip, "FlipX", true, GUI.skin.GetStyle("LightFoldout"));
        bool flipy = EditorGUI.Foldout(VxlGUI.GetLeftElement(rect_row, 1, two), _addpat.yflip, "FlipY", true, GUI.skin.GetStyle("LightFoldout"));

        //apply change
        if (EditorGUI.EndChangeCheck())
        {
            _addpat       = new LateralPattern(flipx, flipy, p0, p1, a0, b0, a1, b1);
            _repaint_menu = false;
        }
        //draw pattern header
        VxlGUI.DrawRect(_rect_patheader, "DarkGradient");
        GUI.Label(_rect_patheader, "Patterns", GUI.skin.GetStyle("LeftLightHeader"));
        //draw pattern list
        VxlGUI.DrawRect(_rect_patscroll, "DarkWhite");
        _patscroll = GUI.BeginScrollView(_rect_patscroll, _patscroll, _rect_patcontent);
        _patternlist.DoList(_rect_patcontent);
        GUI.EndScrollView();
        //draw pattern panel
        VxlGUI.DrawRect(_rect_patpanel, "DarkGradient");
        float button_width = Mathf.Min(60f, _rect_patpanel.width / 2f);

        bool invalid_addpat    = !_addpat.IsValid() || _addpat.IsEmpty();
        bool invalid_edgeindex = _edgelist.count <= 0 || _edgelist.index < 0 || _edgelist.index >= _edgelist.count;
        bool invalid_exists    = target != null && target.LateralPatternExists(_addpat);

        EditorGUI.BeginDisabledGroup(target == null || invalid_addpat || invalid_edgeindex || invalid_exists);
        if (GUI.Button(VxlGUI.GetRightElement(_rect_patpanel, 0, button_width), "Add", GUI.skin.GetStyle("LightButton")))
        {
            if (target != null)
            {
                Undo.RecordObject(target, "Add Lateral Pattern");
                target.AddLateralPattern(_edges[_edgelist.index], _addpat);
                _repaint_menu = false;
                //dirty target
                EditorUtility.SetDirty(target);
                //update pattern list
                UpdatePatternList();
            }
        }
        EditorGUI.EndDisabledGroup();

        bool invalid_patternindex = _patternlist.count <= 0 || _patternlist.index < 0 || _patternlist.index >= _patternlist.count;

        EditorGUI.BeginDisabledGroup(target == null || invalid_edgeindex || invalid_patternindex);
        if (GUI.Button(VxlGUI.GetLeftElement(_rect_patpanel, 0, button_width), "Delete", GUI.skin.GetStyle("LightButton")))
        {
            if (target != null)
            {
                Undo.RecordObject(target, "Delete Lateral Pattern");
                target.DeleteLateralPattern(_edges[_edgelist.index], _patterns[_patternlist.index]);
                _repaint_menu = false;
                //dirty target
                EditorUtility.SetDirty(target);
                //update pattern list
                UpdatePatternList();
            }
        }
        EditorGUI.EndDisabledGroup();
    }