Adnan Faize
Adnan Faize

Reputation: 11

Is there a way to add a button in the unity editor like unity services?

unity services button

I would want to make a button like this. Is there a way or is it just not possible?

I looked over the documentation but couldn't find what I was looking for. Just buttons for the inspector, menu items, and the tools overlay, but it's not what I'm looking for. Maybe it is that I just don't know how to look for something on the internet, if that's the case sorry for the inconvenience. And if you have an idea I would appreciate you share it. Thank you for taking the time.

Upvotes: 0

Views: 770

Answers (1)

derHugo
derHugo

Reputation: 90813

Not on a PC but this is the source code of the Account Drop-down you see the usage of EditorToolbarElementAttribute

[EditorToolbarElement("Services/Account", typeof(DefaultMainToolbar))]
sealed class AccountDropdown : EditorToolbarDropdown
{
    ...

and then in your case inherit from EditorToolbarButton instead.

Also see the source code of DefaultMainToolbar

-> possible that it is not that easy to add additional items as seemingly there needs to be a spot reserved for the button - can't verify this right now

Also note that the type is internal so you don't have direct access to it! You need a bridge assembly .. e.g. naming your assembly Unity.InternalAPIEditorBridge001, this works because unity exposes their internal types accessible to assemblies with certain names

Upvotes: 0

Related Questions