예제 #1
0
        public static void PingObject(Rect rect, string label, Object obj, Type type)
        {
            float labelWidth = string.IsNullOrEmpty(label) ? 0 : textStyleLeft.CalculateTextWidth(label);
            Rect  labelRect  = new Rect(rect.x, rect.y, labelWidth, rect.height);
            float space      = string.IsNullOrEmpty(label) ? 0 : 5;
            Rect  objectRect = new Rect(labelRect.xMax + space, rect.y, rect.width - labelRect.width - space, rect.height);

            string objectText = obj == null ? "None (" + type.Name + ")" : obj.name;

            Label(labelRect, label, textStyleLeft);

            DrawSolidTexture(objectRect, pingFieldBackgroundColor.color);
            DrawSolidTexture(objectRect, pingFieldOutlineColor.color, new BorderWidth(1));
            Label(objectRect, objectText, textStyleLeft);

            if (Event.current.IsMouseDown(MouseButton.Any))
            {
                if (Event.current.IsMouseInsideRect(objectRect))
                {
                    UnityEditor.EditorGUIUtility.PingObject(obj);
                    Event.current.Use();
                }
            }
        }