Exemple #1
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 void ListGUI(AddComponentWindow.Element[] tree, float anim, AddComponentWindow.GroupElement parent, AddComponentWindow.GroupElement grandParent)
        {
            anim = Mathf.Floor(anim) + Mathf.SmoothStep(0f, 1f, Mathf.Repeat(anim, 1f));
            Rect position = base.position;

            position.x       = base.position.width * (1f - anim) + 1f;
            position.y       = 30f;
            position.height -= 30f;
            position.width  -= 2f;
            GUILayout.BeginArea(position);
            Rect   rect = GUILayoutUtility.GetRect(10f, 25f);
            string name = parent.name;

            GUI.Label(rect, name, AddComponentWindow.s_Styles.header);
            if (grandParent != null)
            {
                Rect position2 = new Rect(rect.x + 4f, rect.y + 7f, 13f, 13f);
                if (Event.current.type == EventType.Repaint)
                {
                    AddComponentWindow.s_Styles.leftArrow.Draw(position2, false, false, false, false);
                }
                if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
                {
                    this.GoToParent();
                    Event.current.Use();
                }
            }
            if (parent is AddComponentWindow.NewScriptElement)
            {
                (parent as AddComponentWindow.NewScriptElement).OnGUI();
            }
            else
            {
                this.ListGUI(tree, parent);
            }
            GUILayout.EndArea();
        }
        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();
        }