Esempio n. 1
0
        private void DrawKeywordsList(ref Rect rect, List <string> keywords, bool clickingAddsToSelected)
        {
            rect.height = this.CalcVerticalSpaceForKeywords();
            List <string> list = (from k in keywords
                                  select(!string.IsNullOrEmpty(k)) ? k.ToLowerInvariant() : "<no keyword>").ToList <string>();

            GUI.BeginGroup(rect);
            Rect        rect2             = new Rect(4f, 0f, rect.width, rect.height);
            List <Rect> flowLayoutedRects = EditorGUIUtility.GetFlowLayoutedRects(rect2, EditorStyles.miniButton, 2f, 2f, list);

            for (int i = 0; i < list.Count; i++)
            {
                if (this.KeywordButton(flowLayoutedRects[i], list[i], rect.size))
                {
                    if (clickingAddsToSelected)
                    {
                        this.m_SelectedKeywords.Add(keywords[i]);
                        this.m_SelectedKeywords.Sort();
                    }
                    else
                    {
                        this.m_SelectedKeywords.Remove(keywords[i]);
                    }
                    this.ApplyKeywordFilter();
                    GUIUtility.ExitGUI();
                }
            }
            GUI.EndGroup();
            rect.y += rect.height;
        }
        void DrawKeywordsList(ref Rect rect, List <string> keywords, bool clickingAddsToSelected)
        {
            rect.height = CalcVerticalSpaceForKeywords();
            var displayKeywords = keywords.Select(k => string.IsNullOrEmpty(k) ? "<no keyword>" : k.ToLowerInvariant()).ToList();

            GUI.BeginGroup(rect);
            Rect indentRect  = new Rect(4, 0, rect.width, rect.height);
            var  layoutRects = EditorGUIUtility.GetFlowLayoutedRects(indentRect, EditorStyles.miniButton, 2, 2, displayKeywords);

            for (var i = 0; i < displayKeywords.Count; ++i)
            {
                if (KeywordButton(layoutRects[i], displayKeywords[i], rect.size))
                {
                    if (clickingAddsToSelected)
                    {
                        m_SelectedKeywords.Add(keywords[i]);
                        m_SelectedKeywords.Sort();
                    }
                    else
                    {
                        m_SelectedKeywords.Remove(keywords[i]);
                    }
                    ApplyKeywordFilter();
                    GUIUtility.ExitGUI();
                }
            }
            GUI.EndGroup();
            rect.y += rect.height;
        }
Esempio n. 3
0
        private void DrawKeywordsList(ref Rect rect, List <string> keywords, bool clickingAddsToSelected)
        {
            rect.height = this.CalcVerticalSpaceForKeywords();
            List <string> list = keywords.Select <string, string>((Func <string, string>)(k =>
            {
                if (string.IsNullOrEmpty(k))
                {
                    return("<no keyword>");
                }
                return(k.ToLowerInvariant());
            })).ToList <string>();

            GUI.BeginGroup(rect);
            List <Rect> flowLayoutedRects = EditorGUIUtility.GetFlowLayoutedRects(new Rect(4f, 0.0f, rect.width, rect.height), EditorStyles.miniButton, 2f, 2f, list);

            for (int index = 0; index < list.Count; ++index)
            {
                if (this.KeywordButton(flowLayoutedRects[index], list[index], rect.size))
                {
                    if (clickingAddsToSelected)
                    {
                        this.m_SelectedKeywords.Add(keywords[index]);
                        this.m_SelectedKeywords.Sort();
                    }
                    else
                    {
                        this.m_SelectedKeywords.Remove(keywords[index]);
                    }
                    this.ApplyKeywordFilter();
                    GUIUtility.ExitGUI();
                }
            }
            GUI.EndGroup();
            rect.y += rect.height;
        }