Пример #1
0
        public void Draw()
        {
            //var h = 18;
            //var d = showContent ? 2 : 0;
            //var r = GUILayoutUtility.GetRect(Screen.width-18f, 18);

            GUILayout.Box("", GUIStyle.none, GUILayout.Height(16f));
            var r = GUILayoutUtility.GetLastRect();

            //if (showContent) GUI.Box(r.AddHeight(-5),"");

            /*GUILayout.BeginHorizontal();
             * //var r = GUILayoutUtility.GetRect(20, 20);
             * //GUI.DrawTexture(r, vlbGUISkin.icoEye(showContent));
             * if (GUILayout.Button(vlbGUISkin.icoEye(showContent), EditorStyles.label)) {
             *      showContent = !showContent;
             * }
             *
             * activeIdx = GUILayout.Toolbar(activeIdx, TabList);
             * GUILayout.FlexibleSpace();
             * GUILayout.EndHorizontal();*/
            if (showContent)
            {
                TabDrawer[activeIdx]();
            }

            if (GUI.Button(r.w(20f).dx(2).dy(1), EditorResource.GetTexture2D("eye"), EditorStyles.label))
            {
                showContent = !showContent;
            }

            activeIdx = GUI.Toolbar(r.dx(25).dw(-3).dh(0), activeIdx, TabList);
        }
Пример #2
0
        static internal void Draw(h2Info info, Rect r, GameObject go)
        {
            if (h2Info.SelectionCount < 2)
            {
                return;
            }

            var idx = Array.IndexOf(h2Info.SelectedInstIDs, info.instID);

            if (idx == -1)
            {
                return;
            }

            using (GuiX.GUIColor(go == Selection.activeGameObject ? Color.red : Color.white)) {
                GUI.DrawTexture(r, EditorResource.GetTexture2D("circle"));
            }

            if (r.xLMB_isDown().noModifier)
            {
                //var instList = Selection.instanceIDs;
                Selection.activeInstanceID = go.GetInstanceID();
                Selection.instanceIDs      = h2Info.SelectedInstIDs;
            }
        }
Пример #3
0
        internal h2Lock()
        {
            texList = new[] {
                EditorResource.GetTexture2D("lock_dis"),
                EditorResource.GetTexture2D("lock")
            };

            texColor = new[] {
                h2Color.Get(h2ColorType.Unlock),
                h2Color.Get(h2ColorType.Lock)
            };
        }
Пример #4
0
    /*public static Rect xDrawSubLabel(this Rect r, string title, bool left = true, Vector2? offset = null, GUIStyle style = null) {
     *  if (style == null) style = EditorStyles.label;
     *  var w = style.CalcSize(new GUIContent(title)).x;
     *  GUI.Label(r.xExtractSub(w, out r, left, offset), title, style);
     *  return r;
     * }*/

    public static Rect xDrawL_Arrow(this Rect r, ref bool isExpand, float dx = 0f, float dy = 2f, Color?c = null)
    {
        using (GuiX.GUIColor(c != null ? c.Value : ColorHSL.gray.xProSkinAdjust())) {
            var subRect = r.xExtractSub(16f, out r).h(16f).dx(dx).dy(dy);
            GUI.DrawTexture(subRect, EditorResource.GetTexture2D(isExpand ? "arrow_d" : "arrow_r"));
            if (subRect.xLMB_isDown().noModifier)
            {
                isExpand = !isExpand;
            }
        }
        return(r);
    }
Пример #5
0
        internal h2Static()
        {
            texList = new[] {
                EditorResource.GetTexture2D("lighting"),
                EditorResource.GetTexture2D("lighting")
            };

            texColor = new[] {
                h2Color.Get(h2ColorType.NotStatic),
                h2Color.Get(h2ColorType.Static)
            };
        }
Пример #6
0
    /*public static void xDrawTextureColor(this Rect r, Texture2D tex, Color c) {
     *  var oColor = GUI.color;
     *  GUI.color = c;
     *  GUI.DrawTexture(r, tex);
     *  GUI.color = oColor;
     *
     *  if (r.xLMB_isDown().noModifier) {
     *      EditorGUIUtility.DrawColorSwatch(r.dy(20f).w(200), c);
     *  }
     * }
     *
     *
     *
     * public static Rect xDrawBar(Color? c = null) {
     *  var rect = GUILayoutUtility.GetRect(0, Screen.width, 20f, 20f);
     *  xDrawBar(rect);
     *  return rect;
     * }
     *
     * public static Rect xDrawBar(this Rect r) {
     *  GUI.DrawTexture(r, c.xGetTexture2D());
     *  return r;
     * }
     *
     * public static Rect xDrawTitleBar(string title, float lbOffset = 0, Vector4? padding = null) {
     *
     *  return xDrawTitleBar(r, title, lbOffset, padding);
     * }
     *
     * public static Rect xDrawTitleBar(Rect r, string title, float lbOffset = 0, Vector4? padding = null) {
     *  if (padding != null) r = r.xOffset(padding.Value);
     *  var c = _titleBarColor;
     *
     *  GUI.DrawTexture(r, c.xGetTexture2D());
     *  GUI.Label(r.dy(2f).dx(lbOffset), title, EditorStyles.boldLabel);
     *  return r;
     * }
     * public static Rect xDrawSub(this Rect r, Action<Rect> drawer, float w, bool left = true, float offset = 0) {
     *  Rect subRect;
     *  r = left ? r.xLeft(out subRect, w) : r.xRight(out subRect, w);
     *  drawer(subRect.dx(offset));
     *  return r;
     * }
     *
     * public static Rect xDrawSubArrow(this Rect r, ref bool isExpand, bool left = true, float dx = 0, Color? c = null) {
     *  var expand = isExpand;
     *
     *  r = r.xDrawSub(subRect => {
     *      using (GUIColor(c != null ? c.Value : ColorHSL.gray.xProSkinAdjust())) {
     *          var drawRect = subRect.wh(16f, 16f).dy(2f);
     *          GUI.DrawTexture(drawRect, EditorResource.GetTexture2D(expand ? "arrow_d" : "arrow_r"));
     *      }
     *
     *      if (subRect.xLMB_isDown().noModifier) {
     *          expand = !expand;
     *      }
     *  }, 16f);
     *
     *  isExpand = expand;
     *  return r;
     * }
     *
     * public static Rect xDrawSubToggle(this Rect r, ref bool isEnable, bool left = true, float dx = 0f) {
     *  var enable = isEnable;
     *
     *  r = r.xDrawSub(subRect => {
     *      enable = GUI.Toggle(subRect, enable, "");
     *  }, 16f);
     *
     *  isEnable = enable;
     *  return r;
     * }
     *
     * public static Rect xDrawSubLabel(this Rect r, string label, GUIStyle style = null, bool left = true, float w = 0f, float dx = 0f) {
     *  if (w == 0) {
     *      if (style == null) style = EditorStyles.label;
     *      w = style.CalcSize(new GUIContent(label)).x;
     *  }
     *
     *  r = r.xDrawSub(subRect => {
     *      GUI.Label(subRect, label, style);
     *  }, w);
     *  return r;
     * }*/



    /*public static void xDrawTitleBar(Rect r, string title, float barDx = 0f) {
     *  var c = _titleBarColor;
     *  GUI.DrawTexture(r.dx(barDx), c.xGetTexture2D());
     *  GUI.Label(r.dy(2f), title, EditorStyles.boldLabel);
     * }
     *
     * public static bool xDrawTitleBar(string title, float titleDx = 0f, Rect? padding = null, bool? isExpand = null) {
     *  var r = GUILayoutUtility.GetRect(0, Screen.width, 20f, 20f);
     *  var c = _titleBarColor;
     *
     *  if (padding != null) r = r.xAdd(padding.Value);
     *
     *  GUI.DrawTexture(r, c.xGetTexture2D());
     *  if (isExpand != null) {
     *      var arrowRect = r.dy(2).wh(16f, 16f);
     *      using (GUIColor(ColorHSL.gray.xProSkinAdjust())) {
     *          GUI.DrawTexture(arrowRect, EditorResource.GetTexture2D(isExpand.Value ? "arrow_d" : "arrow_r"));
     *      }
     *
     *      if (arrowRect.xLMB_isDown().noModifier) {
     *          isExpand = !isExpand.Value;
     *      }
     *
     *      GUI.Label(r.dy(2f).dx(titleDx + 10f), title, EditorStyles.boldLabel);
     *      return isExpand.Value;
     *  }
     *
     *  GUI.Label(r.dy(2f).dx(titleDx), title, EditorStyles.boldLabel);
     *  return true;
     * }
     *
     * public static void xDrawTitleBar(string title, ref bool enable, float barDx = 0f, float toggleDx = 0f) {
     *  var r = GUILayoutUtility.GetRect(0, Screen.width, 20f, 20f);
     *  var c = _titleBarColor;
     *
     *  GUI.DrawTexture(r.dx(barDx), c.xGetTexture2D());
     *
     *  var r2 = r.dy(2f);
     *  GUI.Label(r2, title, EditorStyles.boldLabel);
     *  enable = GUI.Toggle(r2.xSubRectRight(20f).dx(toggleDx), enable, "");
     * }*/


    public static void DrawResource(ref string[] icons, ref Color[] colors)
    {
        var   rr    = GUILayoutUtility.GetRect(80, 20f).wh(80f, 20f).xHzSplitByWeight(1, 1, 1, 1);
        Color light = new Color32(192, 192, 192, 255);
        Color dark  = new Color32(49, 49, 49, 255);

        GUI.DrawTexture(rr[0].w(40f), dark.xGetTexture2D());
        GUI.DrawTexture(rr[0].dx(40f).w(40f), light.xGetTexture2D());

        var oColor = GUI.color;

        for (var i = 0; i < icons.Length; i++)
        {
            GUI.color = colors[i];
            GUI.DrawTexture(rr[i].wh(16f, 16f), EditorResource.GetTexture2D(icons[i]));
        }

        GUI.color = oColor;
    }
Пример #7
0
        internal h2Active()
        {
            texList = new[] {
                EditorResource.GetTexture2D("eye_dis"),
                EditorResource.GetTexture2D("eye"),
                EditorResource.GetTexture2D("eye_dis")
            };

            texColorOrg = new [] {
                h2Color.Get(h2ColorType.NotActive),
                h2Color.Get(h2ColorType.Active),
                h2Color.Get(h2ColorType.ActiveHalf)
            };

            texColorChanged = new[] {
                h2Color.Get(h2ColorType.NotActiveChanged),
                h2Color.Get(h2ColorType.ActiveChanged),
                h2Color.Get(h2ColorType.ActiveHalfChanged),
            };

            texColor = texColorOrg;

            h2Shortcut.Add(h2Shortcut.TOGGLE_ACTIVE, () => {
                var selection = h2Info.SelectedGameObjects;
                var activeGO  = Selection.activeGameObject;
                var value     = !activeGO.activeSelf;

                if (selection.Length > 1)
                {
                    Undo.RecordObjects(selection, "Toggle Active");
                    foreach (var go in selection)
                    {
                        go.SetActive(value);
                    }
                }
                else
                {
                    activeGO.hToggleActive(true);
                }
            });
        }
Пример #8
0
    virtual protected void Draw(Rect rect, GameObject ptarget, string icon, Color?c = null)
    {
        target = ptarget;

        if (string.IsNullOrEmpty(icon))
        {
            return;
        }

        if (c == null)
        {
            c = (Get(ptarget) ? ColorHSL.yellow.dS(-0.2f).xProSkinAdjust() : ColorHSL.gray.xProSkinAdjust());
        }
        using (GuiX.GUIColor(c.Value))
        {
            GUI.DrawTexture(rect, EditorResource.GetTexture2D(icon));
        }

        if (rect.Contains(Event.current.mousePosition))
        {
            d = 0;
            ReadModifier().ReadMouse().Check();
        }
    }
Пример #9
0
    public void Draw(Action <int, int, string> onReorder   = null,
                     Action <string, string, int> onRename = null,
                     Action <string, int, vlbGUIList <string> > OnRightClick = null,
                     Rect?drawRect = null)
    {
        _needRepaint = false;
        //isExpand = GuiX.xDrawTitleBar(title, 5f, null, isExpand);

        GDrawX.Bar().xDrawL_Arrow(ref isExpand)
        .xDrawL_BoldLabel(title)
        .xDrawSub(subRect => {
            using (GuiX.DisableGroup(editIndex != -1)) {
                if (subRect.dy(2f).xMiniButton("+", false))
                {
                    list.Add("");
                    editIndex    = drawer.CacheList.Count - 1;
                    editName     = "";
                    isExpand     = true;
                    _needRepaint = true;
                }
            }
        }, 16f, false, new Vector2(-2f, 0f));

        //var rAdd = GUILayoutUtility.GetLastRect().xAdjustTL(16).dy(2f).dw(-2f);
        //if (rAdd.xMiniButton("+", false)) {
        //    list.Add("");
        //    editIndex = drawer.CacheList.Count - 1;
        //    editName = "";
        //    isExpand = true;
        //    _needRepaint = true;
        //}

        if (isExpand)
        {
            drawer.Draw((r, v, idx) => {
                //if (idx == 0) Debug.Log("d2StringGUI " + idx + ":" + r);

                if (idx == editIndex)
                {
                    RenameGUI(r);
                }
                else
                {
                    var v1 = EditorGUI.TextField(r.dw(-20f).dt(2f), v);
                    if (v1 != v)
                    {
                        list[idx] = v1;
                        if (onRename != null)
                        {
                            onRename(v, v1, idx);
                        }
                    }

                    //Debug.Log(Event.current + ":" + r.Contains(Event.current.mousePosition) + ":" + GUI.GetNameOfFocusedControl
                    //remove focus when click outside
                    if (GUI.GetNameOfFocusedControl() == focusName && !r.Contains(Event.current.mousePosition) && Event.current.type == EventType.mouseDown)
                    {
                        GUI.FocusControl(null);
                        _needRepaint = true;
                    }

                    /*EditorGUI.LabelField(r.dl(r.width - 80f).dw(-10f).dt(2f).db(-2f), "" + depth * idx,
                     *  GuiX.miniLabelGrayStyle);*/
                }

                //if (v != "Default") { // Can not remove group / Stacks Default
                var remRect = r.xSubRectRight(16f).dx(-4f);
                GUI.DrawTexture(remRect, EditorResource.GetTexture2D("remove"));

                if (remRect.xLMB_isDown().noModifier)
                {
                    //updateComponent(v, null);
                    if (editIndex == idx)
                    {
                        editIndex = -1;
                    }
                    list.RemoveAt(idx);
                    _needRepaint = true;
                }
                //}

                return(18);
            }, onReorder, OnRightClick, null, drawRect);
        }
    }
Пример #10
0
        internal void Draw(List <h2Info> vList)
        {
            Check();
            if (parents == null || parents.Count == 0 || vList == null || vList.Count == 0)
            {
                return;
            }

            if (texList == null)
            {
                c       = h2Color.Get(h2ColorType.ParentLine);
                texList = new[] {
                    EditorResource.GetTexture2D("corner_tr"),
                    EditorResource.GetTexture2D("line_hz"),
                    EditorResource.GetTexture2D("line_vt")
                };
            }

            //for (var i = 0; i < vList.Count; i++) {
            //    if (!_yMap.ContainsKey(vList[i].instID)) {
            //        _yMap.Add(vList[i].instID, vList[i].drawRect.y);
            //    } else {
            //        _yMap[vList[i].instID] = vList[i].drawRect.y;
            //    }
            //}


            if (iList == null)
            {
                iList = new List <int>();
            }
            else
            {
                iList.Clear();
            }

            var l   = parents.Count;
            var fn  = -1;
            var max = -1;

            //Debug.Log("---------------------------------------------------- " + Event.current.type + ":" + vList.Count);

            for (var i = 0; i < vList.Count; i++)
            {
                var info = vList[i];
                if (info == null || info.go == null)
                {
                    continue;
                }

                var count = info.Transform.parentCount;
                if (count > l)
                {
                    continue;
                }

                //Debug.Log(i + ":" + info.go);

                if (count <= max)
                { //back out !
                  //Debug.Log("Back out ... " + i + ":" + max + ":" + count);
                    fn = max;
                    break;
                }

                if (count == l)
                {
                    if (info.go == selected)
                    {
                        selectedY = info.drawRect.y;
                        fn        = i;
                        break;
                    }
                    continue;
                }

                if (info.go == parents[count])
                {
                    max = count;
                    iList.Add(i);

                    if (h2Settings.DrawParentHighlight)
                    {
                        Highlight(info.drawRect);
                    }
                }
            }

            if (fn == -1 && iList.Count == 0)
            { //check for crossing
                var cgo = vList[0].go;


                if (cgo != null)
                {
                    var pList  = cgo.xGetParents(true);
                    var pLevel = -1;
                    var min    = Mathf.Min(pList == null ? 0 : pList.Count, parents.Count) - 1;

                    for (var i = min; i >= 0; i--)
                    {
                        if (pList[i] == parents[i])
                        {
                            pLevel = i;
                            break;
                        }
                    }

                    if (pLevel != -1)       // crossing
                    {
                        if (selectedY == 0f || selectedY > vList[0].drawRect.y)
                        {
                            using (GuiX.GUIColor(c))
                            {
                                DrawLine(0, vList.Count - 1, vList, pLevel + 1, false, false);
                            }
                        }
                    }
                }

                //Debug.Log("Crossing ... " + pLevel + ":" + selectedY + ":" + vList[0].drawRect.y);
            }
            else
            {
                var st = iList.Count > 0 ? iList[0] : fn;
                var ed = iList.Count > 0 ? iList[iList.Count - 1] : fn;

                var stLv = vList[st].Transform.parentCount;
                var edLv = vList[ed].Transform.parentCount;

                //Debug.Log(st + ":" + ed + ":" + fn);

                using (GuiX.GUIColor(c))
                {
                    if (stLv > 0)
                    { // draw from top
                      //Debug.Log("Top ----> " + stLv + ":" + Event.current);
                        DrawLine(0, st, vList, stLv, true, false);
                    }

                    if (fn == -1)
                    { // draw till end
                      //Debug.Log("End ----> " + edLv);
                        DrawLine(ed, vList.Count - 1, vList, edLv + 1, false, true);
                    }
                    else if (fn != max)
                    {
                        iList.Add(fn);
                    }

                    if (iList.Count > 1)
                    {
                        for (var i = 0; i < iList.Count - 1; i++)
                        {
                            //Debug.Log("MID ----> " + vList[iList[i + 1]].go + ":" + iList[i+1]);
                            DrawLine(iList[i], iList[i + 1], vList, vList[iList[i + 1]].Transform.parentCount, true, true);
                        }
                    }
                }
            }
        }