コード例 #1
0
        public static void Toggle()
        {
            Sidebar instance = FindInstance();

            if (instance != null)
            {
                instance.Close();
                Reflow();
            }
            else
            {
                Create();
            }
        }
コード例 #2
0
        static Sidebar Create()
        {
            Rect    rect     = new Rect(0, 0, SIDEBAR_WIDTH, 64);
            Sidebar instance = (Sidebar)EditorWindow.GetWindowWithRect(typeof(Sidebar), rect, false, "");
            Vector2 minSize  = instance.minSize;

            minSize.x        = SIDEBAR_WIDTH;
            minSize.y        = 0;
            instance.minSize = minSize;
            Vector2 maxSize = instance.maxSize;

            maxSize.x        = SIDEBAR_WIDTH;
            instance.maxSize = maxSize;
            instance.Dock();
            return(instance);
        }
コード例 #3
0
 static void OnLoad()
 {
     LoadSettings();
     ThemeManager.OnLoad();
     Sidebar.OnLoad();
 }
コード例 #4
0
        void DrawItem(Rect rect, int index, bool isActive, bool isFocused)
        {
            SidebarItem item = items[index];
            // icon field
            Rect iconRect = rect;

            iconRect.y     += 3;
            iconRect.width  = iconSize + 6;
            iconRect.height = iconSize + 6;
            Color savedColor = GUI.backgroundColor;

            GUI.backgroundColor = backColor;
            GUI.Label(iconRect, iconLabel, EditorResources.dockHeaderStyle);
            GUI.backgroundColor = savedColor;
            Event e = Event.current;

            if (e.type == EventType.ExecuteCommand && e.commandName == "ObjectSelectorUpdated")
            {
                int id = EditorGUIUtility.GetObjectPickerControlID();
                if (id == index)
                {
                    item.icon   = EditorGUIUtility.GetObjectPickerObject() as Texture2D;
                    GUI.changed = true;
                }
            }
            iconRect.x += 3;
            iconRect.y += 3;
            switch (item.function)
            {
            case SidebarItem.Function.SetLayout:
            case SidebarItem.Function.ExecuteMenuItem:
                Sidebar.PrepareGUI();
                bool clicked = Sidebar.DrawIcon(iconRect, item.icon);
                if (clicked)
                {
                    PaneGUI.FocusListElementAt(index);
                    EditorGUIUtility.ShowObjectPicker <Texture2D>(item.icon, false, "", index);
                }
                break;

            case SidebarItem.Function.Separator:
                Sidebar.PrepareGUI();
                Sidebar.DrawSeparator(iconRect, item.icon);
                break;
            }
            // command field
            rect.x       += iconSize + 10;
            rect.y       += 3;
            rect.width   -= iconSize + 10;
            rect.height   = EditorGUIUtility.singleLineHeight;
            item.function = (SidebarItem.Function)EditorGUI.EnumPopup(rect, item.function);
            // command data field
            rect.y += EditorGUIUtility.singleLineHeight + 2;
            switch (item.function)
            {
            case SidebarItem.Function.SetLayout:
                int i = item.layoutName.IsNullOrEmpty() ?
                        0 : ArrayUtility.IndexOf <string>(layouts, item.layoutName);
                i = EditorGUI.Popup(rect, "", i < 0 ? 0 : i, layouts);
                item.layoutName = i == 0 ? "" : layouts[i];
                break;

            case SidebarItem.Function.ExecuteMenuItem:
                item.menuPath = EditorGUI.TextField(rect, item.menuPath);
                break;

            case SidebarItem.Function.Separator:
                item.icon = Resources.separatorIcon;
                break;
            }
        }