private void GoToChild(AddComponentWindow.Element e, bool addIfComponent)
 {
     if (e is AddComponentWindow.NewScriptElement)
     {
         if (!this.hasSearch)
         {
             this.m_ClassName = AssetDatabase.GenerateUniqueAssetPath((e as AddComponentWindow.NewScriptElement).TargetPath());
             this.m_ClassName = Path.GetFileNameWithoutExtension(this.m_ClassName);
         }
     }
     if (e is AddComponentWindow.ComponentElement)
     {
         if (addIfComponent)
         {
             EditorApplication.ExecuteMenuItemOnGameObjects(((AddComponentWindow.ComponentElement)e).menuPath, this.m_GameObjects);
             base.Close();
         }
     }
     else if (!this.hasSearch || e is AddComponentWindow.NewScriptElement)
     {
         this.m_LastTime = DateTime.Now.Ticks;
         if (this.m_AnimTarget == 0)
         {
             this.m_AnimTarget = 1;
         }
         else if (this.m_Anim == 1f)
         {
             this.m_Anim = 0f;
             this.m_Stack.Add(e as AddComponentWindow.GroupElement);
         }
     }
 }
Exemple #2
0
        private List <AddComponentWindow.Element> GetChildren(AddComponentWindow.Element[] tree, AddComponentWindow.Element parent)
        {
            List <AddComponentWindow.Element> list = new List <AddComponentWindow.Element>();
            int num = -1;
            int i;

            for (i = 0; i < tree.Length; i++)
            {
                if (tree[i] == parent)
                {
                    num = parent.level + 1;
                    i++;
                    break;
                }
            }
            if (num == -1)
            {
                return(list);
            }
            while (i < tree.Length)
            {
                AddComponentWindow.Element element = tree[i];
                if (element.level < num)
                {
                    break;
                }
                if (element.level <= num || this.hasSearch)
                {
                    list.Add(element);
                }
                i++;
            }
            return(list);
        }
Exemple #3
0
        private void ListGUI(AddComponentWindow.Element[] tree, AddComponentWindow.GroupElement parent)
        {
            parent.scroll = GUILayout.BeginScrollView(parent.scroll, new GUILayoutOption[0]);
            EditorGUIUtility.SetIconSize(new Vector2(16f, 16f));
            List <AddComponentWindow.Element> children = this.GetChildren(tree, parent);
            Rect rect = default(Rect);

            for (int i = 0; i < children.Count; i++)
            {
                AddComponentWindow.Element element = children[i];
                Rect rect2 = GUILayoutUtility.GetRect(16f, 20f, new GUILayoutOption[]
                {
                    GUILayout.ExpandWidth(true)
                });
                if ((Event.current.type == EventType.MouseMove || Event.current.type == EventType.MouseDown) && parent.selectedIndex != i && rect2.Contains(Event.current.mousePosition))
                {
                    parent.selectedIndex = i;
                    base.Repaint();
                }
                bool flag = false;
                if (i == parent.selectedIndex)
                {
                    flag = true;
                    rect = rect2;
                }
                if (Event.current.type == EventType.Repaint)
                {
                    GUIStyle gUIStyle = (!(element is AddComponentWindow.ComponentElement)) ? AddComponentWindow.s_Styles.groupButton : AddComponentWindow.s_Styles.componentButton;
                    gUIStyle.Draw(rect2, element.content, false, false, flag, flag);
                    if (!(element is AddComponentWindow.ComponentElement))
                    {
                        Rect position = new Rect(rect2.x + rect2.width - 13f, rect2.y + 4f, 13f, 13f);
                        AddComponentWindow.s_Styles.rightArrow.Draw(position, false, false, false, false);
                    }
                }
                if (Event.current.type == EventType.MouseDown && rect2.Contains(Event.current.mousePosition))
                {
                    Event.current.Use();
                    parent.selectedIndex = i;
                    this.GoToChild(element, true);
                }
            }
            EditorGUIUtility.SetIconSize(Vector2.zero);
            GUILayout.EndScrollView();
            if (this.m_ScrollToSelected && Event.current.type == EventType.Repaint)
            {
                this.m_ScrollToSelected = false;
                Rect lastRect = GUILayoutUtility.GetLastRect();
                if (rect.yMax - lastRect.height > parent.scroll.y)
                {
                    parent.scroll.y = rect.yMax - lastRect.height;
                    base.Repaint();
                }
                if (rect.y < parent.scroll.y)
                {
                    parent.scroll.y = rect.y;
                    base.Repaint();
                }
            }
        }
        private List <AddComponentWindow.Element> GetChildren(AddComponentWindow.Element[] tree, AddComponentWindow.Element parent)
        {
            List <AddComponentWindow.Element> elementList = new List <AddComponentWindow.Element>();
            int num = -1;
            int index;

            for (index = 0; index < tree.Length; ++index)
            {
                if (tree[index] == parent)
                {
                    num = parent.level + 1;
                    ++index;
                    break;
                }
            }
            if (num == -1)
            {
                return(elementList);
            }
            for (; index < tree.Length; ++index)
            {
                AddComponentWindow.Element element = tree[index];
                if (element.level >= num)
                {
                    if (element.level <= num || this.hasSearch)
                    {
                        elementList.Add(element);
                    }
                }
                else
                {
                    break;
                }
            }
            return(elementList);
        }
 private void RebuildSearch()
 {
     if (!this.hasSearch)
     {
         this.m_SearchResultTree = null;
         if (this.m_Stack[this.m_Stack.Count - 1].name == "Search")
         {
             this.m_Stack.Clear();
             this.m_Stack.Add(this.m_Tree[0] as AddComponentWindow.GroupElement);
         }
         this.m_AnimTarget = 1;
         this.m_LastTime   = DateTime.Now.Ticks;
         this.m_ClassName  = "NewBehaviourScript";
     }
     else
     {
         this.m_ClassName = this.m_Search;
         string[] array = this.m_Search.ToLower().Split(new char[]
         {
             ' '
         });
         List <AddComponentWindow.Element> list  = new List <AddComponentWindow.Element>();
         List <AddComponentWindow.Element> list2 = new List <AddComponentWindow.Element>();
         AddComponentWindow.Element[]      tree  = this.m_Tree;
         for (int i = 0; i < tree.Length; i++)
         {
             AddComponentWindow.Element element = tree[i];
             if (element is AddComponentWindow.ComponentElement)
             {
                 string text  = element.name.ToLower().Replace(" ", "");
                 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 <AddComponentWindow.Element> list3 = new List <AddComponentWindow.Element>();
         list3.Add(new AddComponentWindow.GroupElement(0, "Search"));
         list3.AddRange(list);
         list3.AddRange(list2);
         list3.Add(this.m_Tree[this.m_Tree.Length - 1]);
         this.m_SearchResultTree = list3.ToArray();
         this.m_Stack.Clear();
         this.m_Stack.Add(this.m_SearchResultTree[0] as AddComponentWindow.GroupElement);
         if (this.GetChildren(this.activeTree, this.activeParent).Count >= 1)
         {
             this.activeParent.selectedIndex = 0;
         }
         else
         {
             this.activeParent.selectedIndex = -1;
         }
     }
 }
        private void CreateComponentTree()
        {
            string[]      submenus                  = Unsupported.GetSubmenus("Component");
            string[]      submenusCommands          = Unsupported.GetSubmenusCommands("Component");
            List <string> list                      = new List <string>();
            List <AddComponentWindow.Element> list2 = new List <AddComponentWindow.Element>();

            for (int i = 0; i < submenus.Length; i++)
            {
                if (!(submenusCommands[i] == "ADD"))
                {
                    string   text  = submenus[i];
                    string[] array = text.Split(new char[]
                    {
                        '/'
                    });
                    while (array.Length - 1 < list.Count)
                    {
                        list.RemoveAt(list.Count - 1);
                    }
                    while (list.Count > 0 && array[list.Count - 1] != list[list.Count - 1])
                    {
                        list.RemoveAt(list.Count - 1);
                    }
                    while (array.Length - 1 > list.Count)
                    {
                        list2.Add(new AddComponentWindow.GroupElement(list.Count, LocalizationDatabase.GetLocalizedString(array[list.Count])));
                        list.Add(array[list.Count]);
                    }
                    list2.Add(new AddComponentWindow.ComponentElement(list.Count, LocalizationDatabase.GetLocalizedString(array[array.Length - 1]), text, submenusCommands[i]));
                }
            }
            list2.Add(new AddComponentWindow.NewScriptElement());
            this.m_Tree = list2.ToArray();
            if (this.m_Stack.Count == 0)
            {
                this.m_Stack.Add(this.m_Tree[0] as AddComponentWindow.GroupElement);
            }
            else
            {
                AddComponentWindow.GroupElement groupElement = this.m_Tree[0] as AddComponentWindow.GroupElement;
                int level = 0;
                while (true)
                {
                    AddComponentWindow.GroupElement groupElement2 = this.m_Stack[level];
                    this.m_Stack[level] = groupElement;
                    this.m_Stack[level].selectedIndex = groupElement2.selectedIndex;
                    this.m_Stack[level].scroll        = groupElement2.scroll;
                    level++;
                    if (level == this.m_Stack.Count)
                    {
                        break;
                    }
                    List <AddComponentWindow.Element> children = this.GetChildren(this.activeTree, groupElement);
                    AddComponentWindow.Element        element  = children.FirstOrDefault((AddComponentWindow.Element c) => c.name == this.m_Stack[level].name);
                    if (element != null && element is AddComponentWindow.GroupElement)
                    {
                        groupElement = (element as AddComponentWindow.GroupElement);
                    }
                    else
                    {
                        while (this.m_Stack.Count > level)
                        {
                            this.m_Stack.RemoveAt(level);
                        }
                    }
                }
            }
            AddComponentWindow.s_DirtyList = false;
            this.RebuildSearch();
        }
        private void ListGUI(AddComponentWindow.Element[] tree, AddComponentWindow.GroupElement parent)
        {
            parent.scroll = GUILayout.BeginScrollView(parent.scroll);
            EditorGUIUtility.SetIconSize(new Vector2(16f, 16f));
            List <AddComponentWindow.Element> children = this.GetChildren(tree, (AddComponentWindow.Element)parent);
            Rect rect1 = new Rect();

            for (int index = 0; index < children.Count; ++index)
            {
                AddComponentWindow.Element e = children[index];
                Rect rect2 = GUILayoutUtility.GetRect(16f, 20f, new GUILayoutOption[1] {
                    GUILayout.ExpandWidth(true)
                });
                if ((Event.current.type == EventType.MouseMove || Event.current.type == EventType.MouseDown) && (parent.selectedIndex != index && rect2.Contains(Event.current.mousePosition)))
                {
                    parent.selectedIndex = index;
                    this.Repaint();
                }
                bool flag = false;
                if (index == parent.selectedIndex)
                {
                    flag  = true;
                    rect1 = rect2;
                }
                if (Event.current.type == EventType.Repaint)
                {
                    (!(e is AddComponentWindow.ComponentElement) ? AddComponentWindow.s_Styles.groupButton : AddComponentWindow.s_Styles.componentButton).Draw(rect2, e.content, false, false, flag, flag);
                    if (!(e is AddComponentWindow.ComponentElement))
                    {
                        Rect position = new Rect((float)((double)rect2.x + (double)rect2.width - 13.0), rect2.y + 4f, 13f, 13f);
                        AddComponentWindow.s_Styles.rightArrow.Draw(position, false, false, false, false);
                    }
                }
                if (Event.current.type == EventType.MouseDown && rect2.Contains(Event.current.mousePosition))
                {
                    Event.current.Use();
                    parent.selectedIndex = index;
                    this.GoToChild(e, true);
                }
            }
            EditorGUIUtility.SetIconSize(Vector2.zero);
            GUILayout.EndScrollView();
            if (!this.m_ScrollToSelected || Event.current.type != EventType.Repaint)
            {
                return;
            }
            this.m_ScrollToSelected = false;
            Rect lastRect = GUILayoutUtility.GetLastRect();

            if ((double)rect1.yMax - (double)lastRect.height > (double)parent.scroll.y)
            {
                parent.scroll.y = rect1.yMax - lastRect.height;
                this.Repaint();
            }
            if ((double)rect1.y >= (double)parent.scroll.y)
            {
                return;
            }
            parent.scroll.y = rect1.y;
            this.Repaint();
        }
        private void CreateComponentTree()
        {
            string[]      submenus         = Unsupported.GetSubmenus("Component");
            string[]      submenusCommands = Unsupported.GetSubmenusCommands("Component");
            List <string> stringList       = new List <string>();
            List <AddComponentWindow.Element> elementList = new List <AddComponentWindow.Element>();

            for (int index = 0; index < submenus.Length; ++index)
            {
                if (!(submenusCommands[index] == "ADD"))
                {
                    string   menuPath = submenus[index];
                    string[] strArray = menuPath.Split('/');
                    while (strArray.Length - 1 < stringList.Count)
                    {
                        stringList.RemoveAt(stringList.Count - 1);
                    }
                    while (stringList.Count > 0 && strArray[stringList.Count - 1] != stringList[stringList.Count - 1])
                    {
                        stringList.RemoveAt(stringList.Count - 1);
                    }
                    while (strArray.Length - 1 > stringList.Count)
                    {
                        elementList.Add((AddComponentWindow.Element) new AddComponentWindow.GroupElement(stringList.Count, LocalizationDatabase.GetLocalizedString(strArray[stringList.Count])));
                        stringList.Add(strArray[stringList.Count]);
                    }
                    elementList.Add((AddComponentWindow.Element) new AddComponentWindow.ComponentElement(stringList.Count, LocalizationDatabase.GetLocalizedString(strArray[strArray.Length - 1]), menuPath, submenusCommands[index]));
                }
            }
            elementList.Add((AddComponentWindow.Element) new AddComponentWindow.NewScriptElement());
            this.m_Tree = elementList.ToArray();
            if (this.m_Stack.Count == 0)
            {
                this.m_Stack.Add(this.m_Tree[0] as AddComponentWindow.GroupElement);
            }
            else
            {
                // ISSUE: object of a compiler-generated type is created
                // ISSUE: variable of a compiler-generated type
                AddComponentWindow.\u003CCreateComponentTree\u003Ec__AnonStorey80 treeCAnonStorey80 = new AddComponentWindow.\u003CCreateComponentTree\u003Ec__AnonStorey80();
                // ISSUE: reference to a compiler-generated field
                treeCAnonStorey80.\u003C\u003Ef__this = this;
                AddComponentWindow.GroupElement groupElement1 = this.m_Tree[0] as AddComponentWindow.GroupElement;
                // ISSUE: reference to a compiler-generated field
                treeCAnonStorey80.level = 0;
label_15:
                while (true)
                {
                    // ISSUE: reference to a compiler-generated field
                    AddComponentWindow.GroupElement groupElement2 = this.m_Stack[treeCAnonStorey80.level];
                    // ISSUE: reference to a compiler-generated field
                    this.m_Stack[treeCAnonStorey80.level] = groupElement1;
                    // ISSUE: reference to a compiler-generated field
                    this.m_Stack[treeCAnonStorey80.level].selectedIndex = groupElement2.selectedIndex;
                    // ISSUE: reference to a compiler-generated field
                    this.m_Stack[treeCAnonStorey80.level].scroll = groupElement2.scroll;
                    // ISSUE: reference to a compiler-generated field
                    // ISSUE: reference to a compiler-generated field
                    treeCAnonStorey80.level = treeCAnonStorey80.level + 1;
                    // ISSUE: reference to a compiler-generated field
                    if (treeCAnonStorey80.level != this.m_Stack.Count)
                    {
                        // ISSUE: reference to a compiler-generated method
                        AddComponentWindow.Element element = this.GetChildren(this.activeTree, (AddComponentWindow.Element)groupElement1).FirstOrDefault <AddComponentWindow.Element>(new Func <AddComponentWindow.Element, bool>(treeCAnonStorey80.\u003C\u003Em__13A));
                        if (element != null && element is AddComponentWindow.GroupElement)
                        {
                            groupElement1 = element as AddComponentWindow.GroupElement;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        goto label_20;
                    }
                }
                // ISSUE: reference to a compiler-generated field
                while (this.m_Stack.Count > treeCAnonStorey80.level)
                {
                    // ISSUE: reference to a compiler-generated field
                    this.m_Stack.RemoveAt(treeCAnonStorey80.level);
                }
                goto label_15;
            }
label_20:
            AddComponentWindow.s_DirtyList = false;
            this.RebuildSearch();
        }