Exemple #1
0
    private void UpdateToolbar()
    {
        string[] names       = new string[] { "None" };
        int      activeIndex = 0;

        if (brushSettings)
        {
            activeIndex = 1;
            names       = brushSettings.Brushes.Select(b => b.name).ToArray();
        }

        toolbar = new EditorToolbar(activeIndex, names);
        UpdateCells();
    }
Exemple #2
0
        VisualElement GetPanelContent(Editor editor)
        {
            if (editor == null)
            {
                return(null);
            }

            var root = editor.CreateInspectorGUI();

            if (root != null)
            {
                return(root);
            }

            // If the Editor does not provide an OnInspectorGUI, try to fall back to a toolbar.
            var inspector = editor.GetType().GetMethod("OnInspectorGUI",
                                                       BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (inspector == null || inspector.DeclaringType != editor.GetType())
            {
                if (editor is ICreateToolbar toolbar)
                {
                    return(EditorToolbar.CreateOverlay(toolbar.toolbarElements, containerWindow));
                }

                if (editor is ICreateHorizontalToolbar horizontal)
                {
                    return(horizontal.CreateHorizontalToolbarContent());
                }

                if (editor is ICreateVerticalToolbar vertical)
                {
                    return(vertical.CreateVerticalToolbarContent());
                }
            }

            return(new IMGUIContainer(editor.OnInspectorGUI));
        }
Exemple #3
0
        // As a rule, Overlays should be compatible with toolbars or not. This class is an exception, hence the
        // possibility for ICreateToolbar implementations to return null.

        public OverlayToolbar CreateHorizontalToolbarContent()
        {
            var root = new OverlayToolbar();

            if (m_ContextEditor is ICreateHorizontalToolbar ctx)
            {
                root.Add(ctx.CreateHorizontalToolbarContent());
            }
            else if (m_ContextEditor is ICreateToolbar toolbar)
            {
                root.Add(EditorToolbar.CreateOverlay(toolbar.toolbarElements, containerWindow));
            }

            if (m_ToolEditor is ICreateHorizontalToolbar tool)
            {
                root.Add(tool.CreateHorizontalToolbarContent());
            }
            else if (m_ToolEditor is ICreateToolbar toolbar)
            {
                root.Add(EditorToolbar.CreateOverlay(toolbar.toolbarElements, containerWindow));
            }

            return(root);
        }
 public virtual void Display(EditorToolbar inventory)
 {
     _inventory = inventory;
     Refresh();
 }