dbrizov / NaughtyAttributes

Attribute Extensions for Unity
MIT License
4.53k stars 464 forks source link

support easy buttons #356

Open Artemis-chan opened 1 year ago

Artemis-chan commented 1 year ago

This PR simply tries to find EasyButtons assembly and draws the buttons in the NaughtyInspector through that, if the user does not have EasyButtons installed it acts normally. This is to basically get access to Buttons with parameters and NaughtyInspector overrides drawer from EasyButtons, while using EasyButtons as kind of a plugin for NaughtyAttributes.

It might need a editor restart in my experience if EasyButtons is installed after this.

Though if usage of separate EasyButtons assembly is not wanted, I can write support for the button params separately without any external dependencies some time in the coming weeks.

ZeroUltra commented 1 year ago

👍👍👍

Kryloth commented 1 year ago

@Artemis-chan Can you help me man ? Everytime i restart the project, the easy button on the inspector is gone for some reason i've applied this changes too, reinstalled the easy button and naughty attributes but when i close and reopen the project, the button on the inspector is always gone

Artemis-chan commented 1 year ago

@Kryloth How did you install the packages and which Unity version? And are you sure reinstalling did not revert the changes?

Also could you try adding this git package https://github.com/Artemis-chan/NaughtyAttributes.git?path=Assets/NaughtyAttributes#easy-button-support after uninstalling base NaughtyAttributes.

Kryloth commented 1 year ago

@Artemis-chan I'm installing on Unity 2021.3.22f1, i'm sure that what i installed didn't revert the changes since i took a look at the NaughtyInspector script and there's your changes in there i even added a debug log to indicate if it's a success just to make sure everything is fine

if (!BindEasyButtonDrawer())
{
    Debug.LogWarning("EasyButtons drawer definition does not match");
}
else
{
    Debug.Log("EASY BUTTON SUCCESS");
}

At first when i just installed both the Naughty and Easy, it all works fine and the code even logs the debug but whenever i close unity and open it again, all of a sudden the code doesn't work anymore, the button is nowhere to be seen and it doesn't throw the log anymore not even the one with the warning

If you want to i could show you more from my discord, hit me up at Kry#1580

Kryloth commented 1 year ago

@Artemis-chan Hello are you still here ? can you please help me ? i'm not sure what else to do and i've tried all things i could think of but it's still doesn't work please i really need this functionality for my work

Artemis-chan commented 1 year ago

@Kryloth please be patient, I was busy then taking a break. Could you tell me how exactly did you install the plugins? And did you trying installing the git package I linked?

Kryloth commented 1 year ago

@Artemis-chan oh no worries, sorry i thought you might be forgotting I cannot install it from the git package straight from unity package manager for some reason so i installed it by downloading the files from that git link and importing them manually into unity

Artemis-chan commented 1 year ago

@Kryloth oh sorry there was typo in the link try this https://github.com/Artemis-chan/NaughtyAttributes.git?path=Assets/NaughtyAttributes#easy-button-support

Kryloth commented 1 year ago

@Artemis-chan It works only for the first time after i installed it, if i restarted unity it doesn't work anymore Before image

After image

Artemis-chan commented 1 year ago

@Kryloth could you create a new project with the issue present and send me that in a zip file? Just a empty project with just the issue reproduced. I can't seem to produce it.

Kryloth commented 1 year ago

@Artemis-chan Okay first of all let me apologize.., turns out the problem was because in addition to NaughtyAttributes i also use another plugin called MyBox because it has some functionalities that i wanted that isn't in NaughtyAttributes

Looks like i'll have to choose between MyBox and NA with EasyButtons 😞

Artemis-chan commented 1 year ago

@Kryloth no worries at least you found the cause. Yeah, can't do anything about this that other plugin seem to have a lot of overlapping functionality with NA and takes control of Inspector instead.

imniko commented 1 year ago

It is possible to use all 3 on a single project, although with some compromise (foldouts being drawn out of order), the changes are not straight forward as all 3 package source need some changing.

The basic idea is to have only one script with [CustomEditor(typeof(Object)] in the whole project. then merge the contents of UnityObjectEditor.cs (MyBox), ObjectEditor.cs (EasyButtton) and NaughtyInspector.cs into one file.