예제 #1
0
        internal static void Draw(h2Info info, Rect r, GameObject go)
        {
            checkPrefab(info);

            if (info.Prefab == null)
            {
                return;
            }

            using (GuiX.DisableGroup(info.Prefab.type == PrefabType.MissingPrefabInstance)) {
                if (r.xMiniTag(info.Prefab.label, getTexture(info.Prefab.type)))
                {
                    go.xSelectPrefab();
                }
            }
        }
예제 #2
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);
        }
    }