marijnz / unity-toolbar-extender

Extend the Unity Toolbar with your own Editor UI code.
MIT License
1.67k stars 168 forks source link

Remove default UI elements #8

Open CianNoonan opened 5 years ago

CianNoonan commented 5 years ago

It would be great to have the ability to move/edit/remove the existing toolbar buttons for further flexibility.

Having these take up less space would be great. image

marijnz commented 5 years ago

I very quickly tried to just draw over it with the toolbar color. This "works", except for that the elements underneath still respond (and have priority over custom buttons added). I'm pretty sure that what you're suggesting is possible, but it wouldn't have priority for me to do now, maybe you or someone else can do it!

image

CianNoonan commented 5 years ago

Ha, that's one way of doing it. If I can get it to work I'll submit a PR

CianNoonan commented 5 years ago

How did you draw over the top of the existing buttons? I feel I'm missing something here

marijnz commented 5 years ago

Made an example branch, here's the commit: https://github.com/marijnz/unity-toolbar-extender/commit/c44faf216120d381fbf70eecb520e4c000276a65

marijnz commented 5 years ago

And, any progress? :)

CianNoonan commented 5 years ago

I definitely was being silly, I can see that I just needed to expand the drawable area to draw over the buttons.

So far I've managed to prevent the tooltips from showing by setting GUIUtility.hotControl to a value other than 0(i.e 1000). This leads me to believe that these buttons completely circumvent the normal interface.

I'll keep toying with it in my spare time and see if there's a better solution using reflection.

Novack commented 5 years ago

Moving the buttons would be pretty useful, Im considering inserting new stuff, but keeping whats there by default (in the same order, etc) but displaced.

@marijnz in your opinion this should be feasible?

marijnz commented 5 years ago

Looking quickly at the code, I guess it would be possible to take the children from the toolbar here: https://github.com/marijnz/unity-toolbar-extender/blob/9f4c9ba013f8e6cf3c21278e89bd450a16613a08/Assets/ToolbarExtender/Scripts/Editor/ToolbarCallback.cs#L49. Then either draw them or skip them. If somebody wants to try out..

AlirezaTabasi7 commented 4 years ago

Hi there. I tried to select the m_currentToolbar scriptable object to see what's going on in there and guess what? the children list is empty! I also managed to draw a rect over play button in center of toolbar and hooked up my own buttons but the main buttons have higher priority for mouse events and i also tried to tweak GUI.depth variable and also used event system to see if mouse is inside my button rects but there is no luck. Any help would be appreciated.

marijnz commented 3 years ago

FYI, this might be easier with 2021, using Visual Elements.

Novack commented 3 years ago

Thanks for chimming in! I gave this a try time ago without luck, will try again using VE, later this year after updating to U2021.