private void CreateSearchTree(string newSearch)
        {
            string[] array = newSearch.ToLower().Split(new char[]
            {
                ' '
            });
            List <AddStateMachineBehaviourComponentWindow.Element> list  = new List <AddStateMachineBehaviourComponentWindow.Element>();
            List <AddStateMachineBehaviourComponentWindow.Element> list2 = new List <AddStateMachineBehaviourComponentWindow.Element>();

            AddStateMachineBehaviourComponentWindow.Element[] tree = this.m_Tree;
            for (int i = 0; i < tree.Length; i++)
            {
                AddStateMachineBehaviourComponentWindow.Element element = tree[i];
                if (!(element is AddStateMachineBehaviourComponentWindow.NewScriptElement))
                {
                    string text  = element.name.ToLower().Replace(" ", string.Empty);
                    bool   flag  = true;
                    bool   flag2 = false;
                    for (int j = 0; j < array.Length; j++)
                    {
                        string value = array[j];
                        if (!text.Contains(value))
                        {
                            flag = false;
                            break;
                        }
                        if (j == 0 && text.StartsWith(value))
                        {
                            flag2 = true;
                        }
                    }
                    if (flag)
                    {
                        if (flag2)
                        {
                            list.Add(element);
                        }
                        else
                        {
                            list2.Add(element);
                        }
                    }
                }
            }
            list.Sort();
            list2.Sort();
            List <AddStateMachineBehaviourComponentWindow.Element> list3 = new List <AddStateMachineBehaviourComponentWindow.Element>();

            list3.AddRange(list);
            list3.AddRange(list2);
            list3.Add(this.m_Tree[this.m_Tree.Length - 1]);
            this.m_SearchTree  = list3.ToArray();
            this.selectedIndex = 0;
        }
        public void OnGUI()
        {
            if (AddStateMachineBehaviourComponentWindow.s_Styles == null)
            {
                AddStateMachineBehaviourComponentWindow.s_Styles = new AddStateMachineBehaviourComponentWindow.Styles();
            }
            GUI.Label(new Rect(0f, 0f, base.position.width, base.position.height), GUIContent.none, AddStateMachineBehaviourComponentWindow.s_Styles.background);
            this.HandleKeyboard();
            GUILayout.Space(7f);
            AddStateMachineBehaviourComponentWindow.Element activeElement = this.activeElement;
            if (!(activeElement is AddStateMachineBehaviourComponentWindow.NewScriptElement) || !activeElement.IsShow())
            {
                EditorGUI.FocusTextInControl("StateMachineBehaviourSearch");
            }
            Rect rect = GUILayoutUtility.GetRect(10f, 20f);

            rect.x     += 8f;
            rect.width -= 16f;
            GUI.SetNextControlName("StateMachineBehaviourSearch");
            EditorGUI.BeginChangeCheck();
            bool   disabled = activeElement is AddStateMachineBehaviourComponentWindow.NewScriptElement && activeElement.IsShow();
            string search;

            using (new EditorGUI.DisabledScope(disabled))
            {
                search = EditorGUI.SearchField(rect, this.m_Search);
            }
            if (EditorGUI.EndChangeCheck())
            {
                this.m_Search = search;
                EditorPrefs.SetString("StateMachineBehaviourSearchString", this.m_Search);
                this.CreateSearchTree(this.m_Search);
            }
            Rect position = base.position;

            position.x       = 0f;
            position.y       = 30f;
            position.height -= 30f;
            position.width  -= 2f;
            GUILayout.BeginArea(position);
            Rect rect2 = GUILayoutUtility.GetRect(10f, 25f);

            GUI.Label(rect2, this.activeHeader, AddStateMachineBehaviourComponentWindow.s_Styles.header);
            if (this.activeElement is AddStateMachineBehaviourComponentWindow.NewScriptElement && this.activeElement.IsShow())
            {
                this.activeElement.OnGUI(false);
            }
            else
            {
                this.m_ScrollPosition = GUILayout.BeginScrollView(this.m_ScrollPosition, new GUILayoutOption[0]);
                for (int i = 0; i < this.activeTree.Length; i++)
                {
                    if (this.activeTree[i].OnGUI(i == this.selectedIndex))
                    {
                        this.selectedIndex = i;
                        base.Repaint();
                    }
                }
                GUILayout.EndScrollView();
            }
            GUILayout.EndArea();
        }