Пример #1
0
        //------------------------------------------------------
        // gui
        //------------------------------------------------------

        void DrawData(Data data)
        {
            var itemPosition = GUILayoutUtility.GetRect(GUIContent.none, EditorStyles.label, GUILayout.ExpandWidth(true));

            var icon = itemPosition;

            icon.width          = itemPosition.height;
            icon.x              = itemPosition.xMax - icon.width;
            itemPosition.width -= icon.width;

            var e = Event.current;

            switch (e.type)
            {
            case EventType.Repaint:
                icon.x      -= 2;
                icon.width  += 4;
                icon.y      -= 2;
                icon.height += 4;
                GUI.DrawTexture(icon, m_icons[(int)data.message.type]);
                break;

            case EventType.MouseDown:
                if (icon.Contains(e.mousePosition) && e.button == 0)
                {
                    AssetMessageBoard.Open(data.message.guid, data.message, GUIUtility.GUIToScreenPoint(e.mousePosition));
                    e.Use();
                }
                break;
            }

            EditorGUI.ObjectField(itemPosition, data.asset, typeof(Object), false);
        }
Пример #2
0
        //------------------------------------------------------
        // gui
        //------------------------------------------------------

        static void OnGUI(string guid, Rect selectionRect)
        {
            AssetMessageData msg;

            if (!m_dataMap.TryGetValue(guid, out msg))
            {
                return;
            }

            bool twoColumnLayout = (selectionRect.width / selectionRect.height) < 1f;
            var  itemPosition    = GetIconRect(selectionRect, twoColumnLayout);

            var e         = Event.current;
            var controlId = EditorGUIUtility.GetControlID(FocusType.Passive);

            switch (e.GetTypeForControl(controlId))
            {
            case EventType.Repaint:
                // ちょっと大きくしとこ
                if (!twoColumnLayout)
                {
                    itemPosition.x      -= 2;
                    itemPosition.width  += 4;
                    itemPosition.y      -= 2;
                    itemPosition.height += 4;
                }
                GUI.DrawTexture(itemPosition, m_icons[(int)msg.type]);
                break;

            case EventType.MouseDown:
                if (itemPosition.Contains(e.mousePosition) && e.button == 0)
                {
                    AssetMessageBoard.Open(guid, msg, GUIUtility.GUIToScreenPoint(e.mousePosition));
                    e.Use();
                }
                break;
            }
        }