Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
        internal static void CustomScriptGUI()
        {
            //showCustomScript = GuiX.xDrawTitleBar(" Custom Scripts", 0, new Rect(-9f, 0, 0, 0), showCustomScript);
            GDrawX.Bar(BarOffset).xDrawL_Arrow(ref showCustomScript).xDrawL_BoldLabel("Custom Scripts");//.xDrawR_Toggle(ref showCustomScript)
            if (!showCustomScript)
            {
                return;
            }

            if (customScripts == null)
            {
                customScripts = h2Settings.customScripts;
            }
            using (GuiX.xScrollView(ref scrollPos)) {
                for (var i = 0; i < customScripts.Length; i++)
                {
                    var cs = customScripts[i];

                    using (GuiX.hzLayout) {
                        cs.name        = EditorGUILayout.TextField(cs.name, GUILayout.Width(180f));
                        cs.displayName = EditorGUILayout.TextField(cs.displayName, GUILayout.Width(180f));
                        EditorGUILayout.Space();
                    }
                }
            }
        }
Ejemplo n.º 3
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);
    }
Ejemplo n.º 4
0
    internal static void ShortcutGUI()
    {
        var useShortcut = h2Settings.enableShortcut;

        GuiX.xDrawTitleBar("SHORTCUT", ref useShortcut, -9f, -40f);
        h2Settings.enableShortcut = useShortcut;

        using (GuiX.hzLayout)
        {
            EditorGUI.BeginDisabledGroup(!useShortcut);
            h2Settings.use_Alt_Shortcut    = GuiX.GLToggle(h2Settings.use_Alt_Shortcut, "Alt + Key", 130);
            h2Settings.use_Shift_Shortcut  = GuiX.GLToggle(h2Settings.use_Shift_Shortcut, "Shift + Key", 130);
            h2Settings.use_Single_Shortcut = GuiX.GLToggle(h2Settings.use_Single_Shortcut, "Key", 130);
            EditorGUI.EndDisabledGroup();
        }
    }
Ejemplo n.º 5
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();
                }
            }
        }
Ejemplo n.º 6
0
        internal static void ShortcutGUI()
        {
            var useShortcut = h2Settings.enableShortcut;

            GDrawX.Bar(BarOffset).xDrawL_BoldLabel("SHORTCUT").xDrawR_Toggle(ref useShortcut);//.xDrawL_Arrow(ref showCustomScript)
            h2Settings.enableShortcut = useShortcut;

            using (GuiX.hzLayout)
            {
                EditorGUI.BeginDisabledGroup(!useShortcut);
                h2Settings.use_Alt_Shortcut    = GuiX.GLToggle(h2Settings.use_Alt_Shortcut, "Alt + Key", 130);
                h2Settings.use_Shift_Shortcut  = GuiX.GLToggle(h2Settings.use_Shift_Shortcut, "Shift + Key", 130);
                h2Settings.use_Single_Shortcut = GuiX.GLToggle(h2Settings.use_Single_Shortcut, "Key", 130);
                EditorGUI.EndDisabledGroup();
            }
        }
Ejemplo n.º 7
0
    void OnGUI()
    {
        Debug.Log("OnGUI Quickfind : " + position);
        position = drawRect;

        using (GuiX.HzLayout2(EditorStyles.toolbar)) {
            if (GUILayout.Button("Find", EditorStyles.toolbarDropDown, GUILayout.Width(LabelW)))
            {
            }
            GUILayout.Space(5f);
            if (uiSearch == null)
            {
                uiSearch = new vlbGUISearch();
            }
            uiSearch.Draw(onSearch);
        }
    }
Ejemplo n.º 8
0
        protected virtual void DrawTarget(Rect rect, GameObject ptarget, int idx = -1)
        {
            target = ptarget;

            if (Event.current.type == EventType.Repaint)   //only do actual draw on Repaint
            {
                if (idx == -1)
                {
                    idx = Get(ptarget) ? 1 : 0;
                }
                using (GuiX.GUIColor(texColor[idx])) {
                    GUI.DrawTexture(rect, texList[idx]);
                }
            }

            if (rect.Contains(Event.current.mousePosition))
            {
                d = 0;
                ReadModifier().ReadMouse().Check();
            }
        }
Ejemplo n.º 9
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();
        }
    }
Ejemplo n.º 10
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);
        }
    }
Ejemplo n.º 11
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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 12
0
        internal void Draw(Func <Rect, T, int, int> onDrawCell,
                           Action <int, int, T> onReorder = null,
                           Action <T, int, vlbGUIList <T> > OnRightClick = null,
                           Action <int, int, T> onBeforeReorder          = null,
                           Rect?drawRect = null)
        {
            NeedRepaint = false;
            const float scrollW = 16f;

            var rect      = drawRect ?? (Theme.AllowScroll ? GuiX.FlexibleSpace() : GuiX.Height(GuiRect.height));
            var hasScroll = (rect.height > 2f) && (GuiRect.height > rect.height);
            var counter   = 0;
            var ch        = 0f;

            if (!Event.current.xIsLayout() && Event.current.xIsNotUsed())              //rect.width > 1f
            {
                rect          = rect.xAdd(Theme.RectOffset);
                GuiRect.x     = rect.x;
                GuiRect.y     = rect.y;
                GuiRect.width = rect.width;

                MousePos = Event.current.mousePosition;
                //Debug.Log(Event.current + ":" + GuiRect);
            }

            var x = GuiRect.x;
            var y = GuiRect.y;
            var w = GuiRect.width;
            var h = GuiRect.height;

            if (hasScroll)
            {
                ScrollRect     = GuiRect.h(rect.height);
                ScrollPosition = GUI.BeginScrollView(ScrollRect, ScrollPosition, GuiRect.dw(-scrollW), false, true);
            }

            //Debug.Log("----> " + x + ":" + y + ":" + w + ":" + h + ":" + Event.current + ":" + hasScroll);
            //Debug.Log("--------------------------> " + Event.current);

            if (Drag.IsDropping)
            {
                HandleDrop(onReorder, onBeforeReorder);
            }
            else if (Drag.IsDragging)
            {
                HandleDrag();
            }
            if (CacheList == null)
            {
                return;
            }



            for (int i = 0; i < CacheList.Count; i++)               //layout
            //var willLog = i < 5 && CacheList.Count == 12;

            {
                T   item  = CacheList[i];
                var info  = GetInfo(i, item).SetWidth(w - (hasScroll ? scrollW : 0)).SetX(x);
                var first = info.CurrentRect.height == 0;

                /*if (RectMap[CacheList[i]] == RectMap[CacheList[0]]) {
                 *  Debug.Log("Invalid <" + i + ">" + string.IsNullOrEmpty((string)(object)item) + ":" + CacheList[0]);
                 * }*/

                //Debug.Log(i + " CHECK :: " + CacheList[0] + ":" + (RectMap[CacheList[0]] == RectMap[CacheList[i]]));


                //info._logChange = i == 0;
                //if (i == 0) Debug.Log(item.GetHashCode() + " Before :: " + info.CurrentRect);

                if (first)
                {
                    info.SetY(y);                    //.SetHeight(Theme.CellHeight);
                }
                info.AnimateStep();

                if (!Drag.IsDragging)
                {
                    if (Drag.IsDropping && counter == Drag.DropIdx)
                    {
                        if (item != Drag.Target)
                        {
                            LIInfo animx = Drag.Info;
                            animx.TweenY(y + ch);
                            ch += animx.CurrentRect.height;
                        }
                    }

                    if (item != Drag.Target)
                    {
                        if (Event.current.type == EventType.layout)
                        {
                            info.SetY(y + ch);
                        }
                        else
                        {
                            info.TweenY(y + ch);
                        }
                    }
                }

                //if (i == 0) Debug.Log(item.GetHashCode() + " After :: " + info.CurrentRect);

                if (item == Drag.Target)
                {
                    continue;
                }

                //if (i == 0) Debug.Log("Before ::" + info.CurrentRect);

                var newH = DrawCell(i != Drag.DragIdx ? onDrawCell : null,
                                    info.CurrentRect,
                                    item, i,
                                    (Drag.Target != null && counter >= Drag.DropIdx) ? counter + 1 : counter);                                     //!(info.Selected==true)

                //if (i == 0) Debug.Log("After ::" + info.CurrentRect);

                if (newH > 0)
                {
                    if (first)
                    {
                        info.SetHeight(newH);
                    }
                    else
                    {
                        info.TweenH(newH);
                    }
                }

                if (info.IsAnimate && !NeedRepaint)
                {
                    NeedRepaint = true;
                }

                if (!Drag.IsDragging && !Drag.IsDropping)
                {
                    if (info.CanDrag && info.CurrentRect.w(Theme.DragWidth).h(20f).xLMB_isDown().noModifier)
                    {
                        StartDrag(i);
                    }
                    else if (info.Selected != null && info.CurrentRect.xLMB_isDown().noModifier)
                    {
                        info.Selected = !info.Selected;
                    }

                    if (OnRightClick != null && info.CurrentRect.xRMB_isDown().noModifier)
                    {
                        OnRightClick(item, i, this);
                    }
                }


                ch += info.CurrentRect.height;
                counter++;
                //if (willLog) Debug.Log(counter + ":" + ch + "::::" + info.CurrentRect);

                //T item0 = CacheList[0];
                //var info0 = GetInfo(item0);
                //Debug.Log(i + " Last ---> " + info0.CurrentRect);
            }

            /*if (Drag.IsDragging) {
             *  //DEBUG
             *  GUI.DrawTexture(GuiRect, Color.yellow.xAlpha(0.2f).xGetTexture2D());
             *  GUI.DrawTexture(new Rect(MousePos.x, MousePos.y, 10, 10), Color.red.xAlpha(0.2f).xGetTexture2D());
             * }*/

            if (Drag.IsDragging)
            {
                ch += Drag.Info.CurrentRect.height;
            }

            if (ch != h && ch > 0)
            {
                GuiRect.height = ch;
                NeedRepaint    = true;
            }

            if (Drag.Target != null)
            {
                LIInfo dragRect = Drag.Info;
                int    newH     = DrawCell(onDrawCell,
                                           Drag.IsDragging ? MouseDragRect : dragRect.CurrentRect,
                                           (T)Drag.Target, Drag.DragIdx,
                                           Drag.DropIdx);
                if (newH > 0)
                {
                    dragRect.SetHeight(newH);
                }
            }

            if (hasScroll)
            {
                GUI.EndScrollView();
            }
        }
Ejemplo n.º 13
0
    internal static void IconsGUI()
    {
        var useIcon = h2Settings.enableIcons;

        GuiX.xDrawTitleBar("ICONS SETTINGS", ref useIcon, -9f, -40f);
        h2Settings.enableIcons = useIcon;
        EditorGUI.BeginDisabledGroup(!useIcon);

        var idx = Hierarchy2.currentIconMode;
        var rr  = GUILayoutUtility.GetLastRect();

        if (iconModesDrawer == null)
        {
            iconModesDrawer = new h2StringBool {
                source = new StringBuilder(h2Settings.iconModes), total = h2Settings.nIcons
            };
        }

        if (modeTitles == null)
        {
            var list = new List <string> {
                "D"
            };
            for (var i = 1; i < h2Settings.nModes; i++)
            {
                list.Add("" + i);
            }
            modeTitles = list.ToArray();
        }

        idx = GUI.Toolbar(rr.r(470f).l(470f - (10f + 20f * h2Settings.nModes)), idx, modeTitles);
        iconModesDrawer.offset = idx * (h2Settings.nIcons + 1);

        if (idx != Hierarchy2.currentIconMode)
        {
            Hierarchy2.currentIconMode = idx;
            EditorX.xDelayCall(WindowX.Hierarchy.Repaint);
        }

        const int nCols = 3;

        using (GuiX.hzLayout) {
            for (var i = 0; i < iconTitles.Length; i++)
            {
                if (i % nCols == 0)
                {
                    GUILayout.BeginVertical();
                }
                iconModesDrawer.Draw(i, (j, v) => GuiX.GLToggle(v, iconTitles[j], 130f));
                if (i % nCols == nCols - 1 || i == iconTitles.Length - 1)
                {
                    GUILayout.EndVertical();
                }
            }
        }


        if (iconModesDrawer.changed)
        {
            //Debug.Log(h2Settings.iconModes + " ---> " + iconModesDrawer.source);
            h2Settings.iconModes = iconModesDrawer.source.ToString();
            //Debug.Log("after ---> " + h2Settings.iconModes);
        }

        EditorGUI.EndDisabledGroup();
    }
Ejemplo n.º 14
0
        //internal void Reset() {

        //}

        //void SetCategory(int idx) {
        //    Category = idx;
        //    CategoryTitle = null;
        //}

        internal void Draw(Action <string> onSearch)
        {
            var evt = Event.current;

            rect = GuiX.FlexibleSpace().dy(2f);
            //Debug.Log("----> "+ rect + ":" + evt);

            //GUI.BeginGroup(rect, "", EditorStyles.toolbar);
            //GUILayout.BeginHorizontal();
            //GUILayoutUtility.GetRect(rect.width, rect.height);
            //GUILayout.EndHorizontal();

            if (TextFieldStyle == null)
            {
                TextFieldStyle = new GUIStyle("ToolbarSeachTextFieldPopup");         // {fixedHeight = 14f};
                CloseBtnStyle  = new GUIStyle("ToolbarSeachCancelButton");
                EmptyBtnStyle  = new GUIStyle("ToolbarSeachCancelButtonEmpty");
                //ToolbarBtnStyle = new GUIStyle(EditorStyles.toolbarPopup) {fixedWidth = CatWidth /*, alignment = TextAnchor.MiddleCenter*/};
            }

            var r2 = rect;

            GUI.SetNextControlName(gID);
            if (gainFocus)
            {
                GUI.FocusControl(gID);
                EditorGUI.FocusTextInControl(gID);

                if (focus && evt.type == EventType.repaint)
                {
                    gainFocus = false;
                }
            }

            focus = GUI.GetNameOfFocusedControl() == gID;

            if (focus)
            {
                //ESC is down without any modifier
                if (evt.type == EventType.KeyDown)
                {
                    Debug.Log("--->" + evt.keyCode);
                }

                if (KeyCode.Escape.xKey_isDown().noModifier)
                {
                    StopSearch();
                }
                if (KeyCode.Return.xKey_isDown().noModifier&& !string.IsNullOrEmpty(SearchTerm))
                {
                    if (onSearch != null)
                    {
                        onSearch(SearchTerm);//, CategoryList[Category]
                    }
                    else
                    {
                        Debug.Log(string.Format("Search for <{0}> has no handler", SearchTerm));
                    }

                    Event.current.Use();
                }
            }
            else
            {
                //normal click without any modifier
                if (rect.xLMB_isDown().noModifier)
                {
                    StartSearch();
                }
                //TODO : Support Validate / ExecuteCommand
                //if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "Find") {
                //	Event.current.Use();
                //	return;
                //} else if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "Find") {
                //	focusSearchBox = true;
                //}
            }

            SearchTerm = EditorGUI.TextField(r2.dw(-20f), SearchTerm ?? "", TextFieldStyle);

            if (GUI.Button(r2.xHzSubRectsRight(20f)[0], string.Empty, SearchTerm == string.Empty ? EmptyBtnStyle : CloseBtnStyle))
            {
                StopSearch();
            }

            //EditorGUI.BeginChangeCheck();
            //GUI.Button(r2.xSlide(1f).dy(-2).w(CatWidth), CategoryTitle ?? (CategoryTitle = CategoryList[Category].Split('&')[0]), ToolbarBtnStyle);

            //if (EditorGUI.EndChangeCheck()) {
            //    var cm = new GenericMenu();
            //    for (var i = 0; i < CategoryList.Length; i++) {
            //        var idx = i;
            //        cm.xAdd(CategoryList[i], () => SetCategory(idx));
            //    }
            //    cm.ShowAsContext();
            //    //EditorUtility.DisplayCustomMenu(r2, CategoryList.ToGUIContent(), Category, null, null);
            //}

            //GUI.EndGroup();
        }
    public override void OnInspectorGUI()
    {
        var canvasAlign = target as RageCanvasAlign;

        if (canvasAlign == null)
        {
            return;
        }

        EditorGUILayout.Separator();
        //---------

        GuiX.Horizontal(() => {//           var icon = (Texture2D)Resources.Load("ragetoolsicon");
//          if (icon != null)
//              GUILayout.Box(icon, GUILayout.MinHeight(22f), GUILayout.MinWidth(22f),
//                              GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false));

            EditorGUILayout.BeginVertical(); {
                GUILayout.Label("Hor:");
            } EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(); {
                //EditorGUIUtility.LookLikeControls(50f, 60f);
                EditorGUIUtility.labelWidth = 50f;
                EditorGUIUtility.fieldWidth = 60f;

                canvasAlign.HorizontalAlign = (RageCanvasAlign.HorizontalAlignType)
                                              EditorGUILayout.EnumPopup(canvasAlign.HorizontalAlign);
            } EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(); {
                GUILayout.Label("Ver:");
            } EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(); {
                //EditorGUIUtility.LookLikeControls(50f, 60f);
                EditorGUIUtility.labelWidth = 50f;
                EditorGUIUtility.fieldWidth = 60f;
                canvasAlign.VerticalAlign   = (RageCanvasAlign.VerticalAlignType)
                                              EditorGUILayout.EnumPopup(canvasAlign.VerticalAlign);
            } EditorGUILayout.EndVertical();
        });

        GuiX.Horizontal(() => {
            //canvasAlign.StartOnly = GUILayout.Toggle(canvasAlign.StartOnly, "Start Only", GUILayout.Width(75f), GUILayout.MaxHeight(18f));
            EditorGUIUtility.labelWidth = 70f;
            //EditorGUIUtility.LookLikeControls(70f);
            canvasAlign.StartOnly       = EditorGUILayout.Toggle("Start Only", canvasAlign.StartOnly, GUILayout.Width(95f), GUILayout.MaxHeight(18f));
            EditorGUIUtility.labelWidth = 62f;
            EditorGUIUtility.fieldWidth = 50f;
            //EditorGUIUtility.LookLikeControls(62f, 50f);
            canvasAlign.UseCameraIdx = EditorGUILayout.Popup(" Camera:", canvasAlign.UseCameraIdx, canvasAlign.CameraNames, GUILayout.MinWidth(130f));
            if (GUILayout.Button(new GUIContent(_updateButton, "Update Camera List"), GUILayout.Width(22f), GUILayout.Height(16f)))
            {
                canvasAlign.UpdateCameraList();
            }
        });

        // For the script to be updated every frame (and re-check the canvas size), setdirty must be unconditional
        // And the function must be iterated on OnGUI, not OnUpdate
        EditorUtility.SetDirty(target);
    }
Ejemplo n.º 16
0
        internal static void Draw(h2Info info, Rect r, GameObject go)
        {
            if (!showComponents)
            {
                return;
            }
            //if ((info.detail & h2iDetail.Component) == 0) info.ReadComponentInfo();

            var arr = info.Component.components;
            var w   = 0;
            var r0  = r.dl(r.width - 16f);

            for (var i = 0; i < arr.Count; i++)
            {
                var c = arr[i];

                if (c == null)
                {
                    continue;
                }
                if (!showUnusual && (c is Transform || c is MeshFilter
#if UNITY_4_6 || UNITY_5
                                     || c is CanvasRenderer
#endif
                                     ))
                {
                    continue;
                }
                if (!showRender && (c is Renderer || c is MeshFilter
#if UNITY_4_6 || UNITY_5
                                    || c is CanvasRenderer
#endif
                                    ))
                {
                    continue;
                }
                if (!showPhysics && (c is Collider || c is Rigidbody || c is Rigidbody2D || c is Collider2D))
                {
                    continue;
                }

                var icon      = AssetPreview.GetMiniThumbnail(c);
                var hasProp   = arr[i].xHasProperty("enabled");
                var willClear = hasProp && !(bool)arr[i].xGetProperty("enabled");

                using (GuiX.GUIColor(willClear ? Color.clear.xAlpha(0.2f) : Color.white)) {// :
                    GUI.DrawTexture(r0, icon);

                    if (Selection.activeGameObject == go && hasProp && r0.xLMB_isDown().noModifier)
                    {
                        Undo.RecordObject(c, "Toggle enable");
                        c.xSetProperty("enabled", willClear);
                        WindowX.Inspector.Repaint();
                    }
                }

                r0 = r0.dx(-16f);
                w += 16;
            }

            if (MaxWidth < w)
            {
                MaxWidth = w;
            }
        }
Ejemplo n.º 17
0
 internal static void MiscGUI()
 {
     GuiX.xDrawTitleBar("MISC", -9f);
 }