Esempio 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;
            }
        }
Esempio n. 2
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);
    }
Esempio n. 3
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();
            }
        }
Esempio n. 4
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();
        }
    }
Esempio n. 5
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;
            }
        }
Esempio n. 6
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);
                        }
                    }
                }
            }
        }