Пример #1
0
        private void DrawItem(TreeItem item)
        {
            if (Event.current.type == EventType.Repaint)
            {
                GUIStyle rowStyle = m_NextRowIndex % 2 == 0 ? BackgroundStyleEven : BackgroundStyleOdd;
                bool     selected = false;
                if (item == m_SelectedItem)
                {
                    //rowStyle = LabelStyle;
                    selected = true;
                }

                rowStyle.Draw(m_NextItemRect, false, false, selected, selected);
            }


            GUIContent label = item.Content;

            Rect labelRect = m_NextItemRect;

            labelRect.xMin += item.Depth * kIndent;
            GUI.enabled     = item.OnSelected != null;
            if (Event.current.type == EventType.Repaint)
            {
                GUIStyle style = LabelStyle;
                if (item.PartiallyTicked)
                {
                    style = MixedLabelStyle;
                }
                bool showTick = item.Ticked | item.PartiallyTicked;
                style.Draw(labelRect, label, false, showTick, showTick, false);
            }
            if ((Event.current.type == EventType.MouseDown) && labelRect.Contains(Event.current.mousePosition))
            {
                //if (GUI.Button(labelRect, label, LabelStyle)) {
                m_SelectedItem = item;
                if (m_SelectedItem.OnSelected != null)
                {
                    m_SelectedItem.OnSelected(item);
                }
                EditorWindow.Close();
            }
            GUI.enabled       = true;
            m_NextItemRect.y += EditorGUIUtility.singleLineHeight;
            m_NextRowIndex   += 1;
        }