Пример #1
0
    private void DrawPatternElementBackground(Rect rect, int index, bool active, bool focus)
    {
        bool hover = (_patternlist.count > 0) && rect.Contains(Event.current.mousePosition);
        bool on    = (_patternlist.count > 0 && _patternlist.index == index);

        VxlGUI.DrawRect(rect, "SelectableGrey", hover, active, on, focus);
    }
Пример #2
0
    public void DrawSocketBackground(Rect rect, int index, bool active, bool focus)
    {
        bool hover = (_sockets.Count > 0) && rect.Contains(Event.current.mousePosition);
        bool on    = selectset.Contains(index);

        VxlGUI.DrawRect(rect, "SelectableGrey", hover, active, on, focus);
    }
Пример #3
0
    private void DrawVertexElementBackground(Rect rect, int index, bool active, bool focus)
    {
        bool hover = (_vertices.Count > 0) && rect.Contains(Event.current.mousePosition);
        bool on    = selectset.Contains(index);

        VxlGUI.DrawRect(rect, "SelectableGrey", hover, active, on, focus);
    }
Пример #4
0
    private void DrawUnsavedElementBackground(Rect rect, int index, bool active, bool focus)
    {
        bool hover = (_unsaveds.Count > 0) && rect.Contains(Event.current.mousePosition);
        bool on    = (_unsaved_selected && _index == index && _index >= 0);

        VxlGUI.DrawRect(rect, "SelectableGrey", hover, active, on, focus);
    }
Пример #5
0
    public void DrawSocketAxiBackground(Rect rect, int index, bool active, bool focus)
    {
        bool hover = (_axilabels.Length > 0) && rect.Contains(Event.current.mousePosition);
        bool on    = (_axilabels.Length > 0) && (index == _axilist.index);

        VxlGUI.DrawRect(rect, "SelectableGrey", hover, active, on, focus);
    }
Пример #6
0
    public override void DrawGUI(Rect rect)
    {
        float width = Mathf.Min(200, rect.width);

        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, "Mesh", true, GUI.skin.GetStyle("LightBoldFoldout"));
            if (EditorGUI.EndChangeCheck())
            {
                _repaint_menu = true;
            }
        }
        else
        {
            float content_height = (2 * VxlGUI.MED_BAR) + VxlGUI.SM_SPACE;
            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, "Mesh", 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);

            //invert x
            int level = 0;
            row_rect = VxlGUI.GetAboveElement(rect_content, level, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
            invertx  = EditorGUI.Foldout(row_rect, invertx, "Invert X", true, GUI.skin.GetStyle("LightFoldout"));
            level   += 1;
            //invert y
            row_rect = VxlGUI.GetAboveElement(rect_content, level, VxlGUI.MED_BAR, VxlGUI.SM_SPACE, 0);
            inverty  = EditorGUI.Foldout(row_rect, inverty, "Invert Y", true, GUI.skin.GetStyle("LightFoldout"));
            level   += 1;

            GUI.EndScrollView();
            if (EditorGUI.EndChangeCheck())
            {
                _repaint_menu = true;
                _render_mesh  = true;
                _update_mesh  = true;
            }
        }
    }
Пример #7
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();
    }
Пример #8
0
    public override void DrawGUI(Rect rect)
    {
        //update and populate lists
        UpdateLists();
        //update layout rects
        UpdateLayoutRect(rect);
        //draw header
        VxlGUI.DrawRect(_rect_header, "DarkGradient");
        GUI.Label(_rect_header, _title, GUI.skin.GetStyle("LeftLightHeader"));
        //GUID
        VxlGUI.DrawRect(_rect_guidscroll, "DarkWhite");
        _guidscroll = GUI.BeginScrollView(_rect_guidscroll, _guidscroll, _rect_guidcontent);
        _guidlist.DoList(_rect_guidcontent);
        GUI.EndScrollView();
        //transfer panel
        bool disable_guid = _guidlist.index < 0 || _guidlist.index >= _guidlist.count;
        bool disable_lib  = _libobjlist.index < 0 || _libobjlist.index >= _libobjlist.count;

        VxlGUI.DrawRect(_rect_panel, "DarkGradient");
        float boundwidth = Mathf.Min(60f, _rect_panel.width / 3f);
        //down button
        Rect rect_button = VxlGUI.GetMiddleX(VxlGUI.GetLeftElement(_rect_panel, 0, boundwidth), _rect_panel.height);

        EditorGUI.BeginDisabledGroup(disable_guid);
        if (GUI.Button(rect_button, "", GUI.skin.GetStyle("ArrowDown")))
        {
            AddSelected();
        }
        EditorGUI.EndDisabledGroup();
        //up button
        rect_button = VxlGUI.GetMiddleX(VxlGUI.GetMiddleX(_rect_panel, boundwidth), _rect_panel.height);
        EditorGUI.BeginDisabledGroup(disable_lib);
        if (GUI.Button(rect_button, "", GUI.skin.GetStyle("ArrowUp")))
        {
            RemoveSelected();
        }
        EditorGUI.EndDisabledGroup();
        //swap button
        rect_button = VxlGUI.GetMiddleX(VxlGUI.GetRightElement(_rect_panel, 0, boundwidth), _rect_panel.height);
        EditorGUI.BeginDisabledGroup(disable_guid || disable_lib);
        if (GUI.Button(rect_button, "", GUI.skin.GetStyle("ArrowSwap")))
        {
            SwapSelected();
        }
        EditorGUI.EndDisabledGroup();
        //library
        VxlGUI.DrawRect(_rect_libscroll, "DarkWhite");
        _libscroll = GUI.BeginScrollView(_rect_libscroll, _libscroll, _rect_libcontent);
        _libobjlist.DoList(_rect_libcontent);
        GUI.EndScrollView();
    }
Пример #9
0
    private void DrawElementBackground(Rect rect, int index, bool active, bool focus, bool is_guid)
    {
        bool hover, on;

        if (is_guid)
        {
            hover = (_guids.Count > 0) && rect.Contains(Event.current.mousePosition);
            on    = (_guidlist.index >= 0 && _guidlist.index == index);
        }
        else
        {
            hover = (_libobjs.Count > 0) && rect.Contains(Event.current.mousePosition);
            on    = (_libobjlist.index >= 0 && _libobjlist.index == index);
        }
        VxlGUI.DrawRect(rect, "SelectableGrey", hover, active, on, focus);
    }
Пример #10
0
    public override void DrawGUI(Rect rect)
    {
        //update plugs
        UpdatePlugs();
        //update layout rects
        UpdateRects(rect);

        EditorGUI.BeginDisabledGroup(target == null || plugs == null);
        //Draw title
        VxlGUI.DrawRect(_rect_title, "DarkGradient");
        GUI.Label(_rect_title, _title, GUI.skin.GetStyle("LeftLightHeader"));
        //draw content
        VxlGUI.DrawRect(_rect_scroll, "DarkWhite");
        _scroll = GUI.BeginScrollView(_rect_scroll, _scroll, _rect_content);
        _pluglist.DoList(_rect_content);
        GUI.EndScrollView();
        EditorGUI.EndDisabledGroup();
    }
Пример #11
0
    public override void DrawGUI(Rect rect)
    {
        RefreshOptionLabels();
        UpdateTriangleList();
        UpdateRects(rect);
        EditorGUI.BeginDisabledGroup(target == null);
        //draw title
        VxlGUI.DrawRect(_rect_title, "DarkGradient");
        GUI.Label(_rect_title, "Triangles", GUI.skin.GetStyle("LeftLightHeader"));
        //draw triangle list
        VxlGUI.DrawRect(_rect_tri_scroll, "DarkWhite");
        _scroll = GUI.BeginScrollView(_rect_tri_scroll, _scroll, _rect_tri_content);
        _trianglelist.DoList(_rect_tri_content);
        GUI.EndScrollView();
        //draw button panel
        VxlGUI.DrawRect(_rect_panel, "DarkGradient");
        float button_width = Mathf.Min(60, _rect_panel.width / 4f);

        //draw add button
        if (GUI.Button(VxlGUI.GetRightElement(_rect_panel, 0, button_width), "Add", GUI.skin.GetStyle("LightButton")))
        {
            AddTriangle();
        }
        //draw add triangle button
        EditorGUI.BeginDisabledGroup(_preview.secondaryCount != 3);
        if (GUI.Button(VxlGUI.GetRightElement(_rect_panel, 1, button_width), "S Add", GUI.skin.GetStyle("LightButton")))
        {
            AddSecondaryTriangle();
        }
        EditorGUI.EndDisabledGroup();
        //draw flip button
        EditorGUI.BeginDisabledGroup((_triangles.Count <= 0) || (selectlist.Count <= 0));
        if (GUI.Button(VxlGUI.GetRightElement(_rect_panel, 2, button_width), "Flip", GUI.skin.GetStyle("LightButton")))
        {
            FlipSelectedTriangles();
        }
        //draw delete button
        if (GUI.Button(VxlGUI.GetLeftElement(_rect_panel, 0, button_width), "Delete", GUI.skin.GetStyle("LightButton")))
        {
            DeleteSelectedTriangles();
        }
        EditorGUI.EndDisabledGroup();
        EditorGUI.EndDisabledGroup();
    }
Пример #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 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;
        }
    }
Пример #13
0
    public override void DrawGUI(Rect rect)
    {
        UpdateModes();
        //update rects
        UpdateRects(rect);
        //tab buttons
        Matrix4x4 matrix = GUI.matrix;

        GUIUtility.RotateAroundPivot(270, _rect_submodes.center);
        int newmode = GUI.SelectionGrid(VxlGUI.CenterInvertRect(_rect_submodes), _mode, _mode_labels, _modes.Length, GUI.skin.GetStyle("SubModeToolbar"));

        //mode switch
        if (newmode != _mode)
        {
            //disable old mode
            _modes[_mode].Disable();
            //enable new mode
            _modes[newmode].Enable();
            _mode = newmode;
            //update new mode
            UpdateModes();
        }
        GUI.matrix = matrix;
        //tab content
        if (_mode >= 0 && _mode < _modes.Length)
        {
            _modes[_mode].DrawGUI(_rect_content);
        }
        //selection background
        VxlGUI.DrawRect(_rect_selected, "DarkGradient");
        //selection label
        string text = "[None]";

        if (selected != null)
        {
            text = selected.objname;
        }
        GUI.Label(_rect_selected, _title + ":  " + text, GUI.skin.GetStyle("LeftLightHeader"));

        UpdateModes();
    }
Пример #14
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;
        }
    }
Пример #15
0
    private void DrawTriangleElementBackground(Rect rect, int index, bool active, bool focus)
    {
        bool hover = (_triangles.Count > 0) && rect.Contains(Event.current.mousePosition);
        bool on    = selectset.Contains(index);
        bool valid = true;

        if (index >= 0 && index < _triangles.Count)
        {
            if (target != null && !target.IsValid())
            {
                valid = _triangles[index].IsValid(target.vertices.Count, target.cornerplugs, target.edgeplugs);
            }
        }
        if (valid)
        {
            VxlGUI.DrawRect(rect, "SelectableGrey", hover, active, on, focus);
        }
        else
        {
            VxlGUI.DrawRect(rect, "SelectableRed", hover, active, on, focus);
        }
    }
Пример #16
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();
    }
Пример #17
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();
    }
Пример #18
0
    public override void DrawGUI(Rect rect)
    {
        //update both visual lists
        UpdateCornerList();
        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);
        _cornerlist.DoList(_rect_select_content);
        GUI.EndScrollView();
        //draw add pattern template
        EditorGUI.BeginChangeCheck();
        VxlGUI.DrawRect(_rect_temparea, "DarkGrey");
        GUI.Label(_rect_tempheader, "Corner Pattern", "PatHeader");
        GUI.Label(_rect_voxelid, "Voxel IDs:", "LeftMedPatLabel");
        GUI.Label(_rect_above, "Above", "RightMedPatLabel");
        GUI.Label(_rect_below, "Below", "RightMedPatLabel");
        GUI.Label(_rect_d5, "D5", "MidMedPatLabel");
        GUI.Label(_rect_d1, "D1", "MidMedPatLabel");
        GUI.Label(_rect_d3, "D3", "MidMedPatLabel");
        int  a0    = EditorGUI.IntField(_rect_above_d5, _addpat.a0, "MidPatIntField");
        int  a1    = EditorGUI.IntField(_rect_above_d1, _addpat.a1, "MidPatIntField");
        int  a2    = EditorGUI.IntField(_rect_above_d3, _addpat.a2, "MidPatIntField");
        int  b0    = EditorGUI.IntField(_rect_below_d5, _addpat.b0, "MidPatIntField");
        int  b1    = EditorGUI.IntField(_rect_below_d1, _addpat.b1, "MidPatIntField");
        int  b2    = EditorGUI.IntField(_rect_below_d3, _addpat.b2, "MidPatIntField");
        bool xflip = EditorGUI.Foldout(_rect_flipx, _addpat.xflip, "FlipX", true, "LightFoldout");
        bool yflip = EditorGUI.Foldout(_rect_flipy, _addpat.yflip, "FlipY", true, "LightFoldout");

        //apply change
        if (EditorGUI.EndChangeCheck())
        {
            _addpat       = new CornerPattern(xflip, yflip, a0, a1, a2, b0, b1, b2);
            _repaint_menu = true;
        }



        bool invalid_corner = _cornerlist.count <= 0 || _cornerlist.index < 0 || _cornerlist.index >= _cornerlist.count;
        bool invalid_exists = target != null && target.CornerPatternExists(_addpat);

        EditorGUI.BeginDisabledGroup(target == null || _addpat.IsEmpty() || invalid_corner || invalid_exists);
        if (GUI.Button(_rect_tempbutton, "Add", GUI.skin.GetStyle("PatButton")))
        {
            if (target != null)
            {
                Undo.RecordObject(target, "Add Corner Pattern");
                target.AddCornerPattern(_corners[_cornerlist.index], _addpat);
                _repaint_menu = false;
                //dirty target object
                EditorUtility.SetDirty(target);
                //update pattern list
                UpdatePatternList();
            }
        }
        EditorGUI.EndDisabledGroup();

        //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_pattern = _patternlist.count <= 0 || _patternlist.index < 0 || _patternlist.index >= _patternlist.count;

        EditorGUI.BeginDisabledGroup(target == null || invalid_pattern || invalid_corner);
        if (GUI.Button(VxlGUI.GetLeftElement(_rect_patpanel, 0, button_width), "Delete", GUI.skin.GetStyle("LightButton")))
        {
            if (target != null)
            {
                Undo.RecordObject(target, "Delete Corner Pattern");
                target.DeleteCornerPattern(_corners[_cornerlist.index], _patterns[_patternlist.index]);
                _repaint_menu = false;
                //dirty target object
                EditorUtility.SetDirty(target);
                //update pattern list
                UpdatePatternList();
            }
        }
        EditorGUI.EndDisabledGroup();
    }
Пример #19
0
    public override void DrawGUI(Rect rect)
    {
        UpdateAxiList();
        UpdateSocketList();
        //update layout rects
        UpdateRects(rect);
        //disable panel condition
        EditorGUI.BeginDisabledGroup(target == null || !target.IsValid());
        VxlGUI.DrawRect(_rect_axititle, "DarkGrey");
        VxlGUI.DrawRect(_rect_axiscroll, "DarkWhite");
        //axi socket title
        GUI.Label(_rect_axititle, _title + " Axi Sockets", "LeftLightHeader");
        //draw list of axi sockets
        _axiscroll = GUI.BeginScrollView(_rect_axiscroll, _axiscroll, _rect_axicontent);
        _axilist.DoList(_rect_axicontent);
        GUI.EndScrollView();

        EditorGUI.BeginDisabledGroup(_axilist.index < 0 || _axilist.index >= _axilist.count);

        //sockets
        VxlGUI.DrawRect(_rect_sockethead, "DarkGrey");
        VxlGUI.DrawRect(_rect_socketbuttonpanel, "DarkGrey");
        VxlGUI.DrawRect(_rect_socketscroll, "DarkWhite");
        //socket title
        string socket_title = "Socket: ";

        if (_socketlist.index < 0 || _socketlist.index >= _axilabels.Length)
        {
            socket_title += "None";
        }
        else
        {
            socket_title += _axilabels[_socketlist.index];
        }
        GUI.Label(_rect_sockettitle, socket_title, "LeftLightHeader");
        //socket list type selection
        EditorGUI.BeginChangeCheck();
        _invx = EditorGUI.Foldout(_rect_invx, _invx, "Invert X", true, "LightBoldFoldout");
        _invy = EditorGUI.Foldout(_rect_invy, _invy, "Invert Y", true, "LightBoldFoldout");
        if (EditorGUI.EndChangeCheck())
        {
            selectlist.Clear();
            selectset.Clear();
            UpdateSocketList();
            _repaint_menu = true;
            _render_mesh  = true;
        }
        //draw list scroll
        _socketscroll = GUI.BeginScrollView(_rect_socketscroll, _socketscroll, _rect_socketcontent);
        _socketlist.DoList(_rect_socketcontent);
        GUI.EndScrollView();

        //add button
        if (GUI.Button(_rect_addsocket, "Add", "LightButton"))
        {
            AddSocketElement();
        }
        //selection add button
        EditorGUI.BeginDisabledGroup(_preview.secondaryCount <= 0);
        if (GUI.Button(_rect_secondaddsocket, "Add S", "LightButton"))
        {
            AddSecondarySelection();
        }
        EditorGUI.EndDisabledGroup();

        //delete button
        EditorGUI.BeginDisabledGroup(selectlist.Count <= 0);
        if (GUI.Button(_rect_delsocket, "Delete", "LightButton"))
        {
            DeleteSelectedSocketVertex();
        }
        EditorGUI.EndDisabledGroup();
        EditorGUI.EndDisabledGroup();
        EditorGUI.EndDisabledGroup();

        _preview.invx = _meshdisplay.invertx;
        _preview.invy = _meshdisplay.inverty;
    }
Пример #20
0
    public override void DrawGUI(Rect rect)
    {
        //update both visual lists
        UpdateFaceList();
        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);
        _facelist.DoList(_rect_select_content);
        GUI.EndScrollView();
        //draw add pattern template
        DrawAddPatternPanel();

        //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.IsEmpty() || !_addpat.IsValid();
        bool invalid_faceindex = _facelist.count <= 0 || _facelist.index < 0 || _facelist.index >= _facelist.count;
        bool invalid_exists    = target == null || target.HexagonPatternExists(_addpat);

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

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

        EditorGUI.BeginDisabledGroup(target == null || invalid_faceindex || invalid_patindex);
        if (GUI.Button(VxlGUI.GetLeftElement(_rect_patpanel, 0, button_width), "Delete", GUI.skin.GetStyle("LightButton")))
        {
            if (target != null)
            {
                Undo.RecordObject(target, "Delete Hexagon Pattern");
                target.DeleteHexagonPattern(_faces[_facelist.index], _patterns[_patternlist.index]);
                _repaint_menu = false;
                //set target dirty
                EditorUtility.SetDirty(target);
                //update pattern list
                UpdatePatternList();
            }
        }
        EditorGUI.EndDisabledGroup();
    }
Пример #21
0
    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;
            }
        }
    }