dbrizov / NaughtyAttributes

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

[Issue] Unity's "Space" and "Tooltip" attributes can't be combined with some of the Naughty attributes #16

Open dbrizov opened 6 years ago

Samhayne commented 5 years ago

When tooltips didn't work for me on the MinMaxSlider I edited the MinMaxPropertyDrawer in the following way:

EditorGUI.LabelField(labelRect, property.displayName); // line 48

... became ...

TooltipAttribute tooltipAttribute = PropertyUtility.GetAttribute<TooltipAttribute>(property); EditorGUI.LabelField(labelRect, new GUIContent(property.displayName, tooltipAttribute != null ? tooltipAttribute.tooltip : ""));

JimmyCushnie commented 4 years ago

Tooltip still does not work with MinMaxSlider

smokelore commented 3 years ago

verifying this is still an issue with MinMaxSlider

Befezdow commented 3 years ago

still reproducible

dbrizov commented 3 years ago

I know it's still reproducible, but I don't know how to fix it. I am just implementing a CustomPropertyDrawer like everything else. It has to do something with the MinMaxSlider which Unity provides

RWOverdijk commented 2 years ago

I noticed this with the MinValue and MaxValue as well.

https://stackoverflow.com/questions/58879682/cannot-add-a-tooltip-to-appear-when-the-mouse-hovers-to-a-unity-editorguilayout

Maybe this helps?

dbrizov commented 2 years ago

I noticed this with the MinValue and MaxValue as well.

https://stackoverflow.com/questions/58879682/cannot-add-a-tooltip-to-appear-when-the-mouse-hovers-to-a-unity-editorguilayout

Maybe this helps?

This is exactly what is happening, some EditorGUILayout functions support tooltips, some don't. I won't be able to fix this bug unless I have Unity's source code.

dbrizov commented 2 years ago

The other solution is to check manually if the properties have [Tooltip] attribute, and add the tooltip myself, but that means I have to make special cases all around the code, because I don't want to display 2 tooltips for the drawers that already support 1 tooltip. Actually, 2 tooltips can't happen, but 2 spaces because of the [Space] attribute can.

neohun commented 2 years ago

Hi, the problem with the tooltip can be fixed with the code on the answer link. I have tried with my custom propertyDrawer, it works like a charm: If you update the codes it'll be fixed properly, link: http://answers.unity.com/answers/1544468/view.html

CreepGin commented 2 years ago

@neohun thx! That set me on the right path. So, for me at least, I was able to fix this issue by removing the label parameter in EditorGUILayout.PropertyField calls. Not sure if this can interfere with some other NaughtyAttributes, but now my foldouts no longer disable tooltips.

neohun commented 2 years ago

@neohun thx! That set me on the right path. So, for me at least, I was able to fix this issue by removing the label parameter in EditorGUILayout.PropertyField calls. Not sure if this can interfere with some other NaughtyAttributes, but now my foldouts no longer disable tooltips.

Glad to hear that, actually all problems caused by unity's terrible custom editor system but anyway (:

ZnelArts commented 2 years ago

Any update on this issue, it seems tooltips are still not working. For me it doesnt show tooltips with any property that I use NaughtyAttributes tags

neohun commented 2 years ago

@ZnelArts Hi, It seems that unity has done some changes and this problem is fixed. If you upgrade your editor to an upper version it should work. I use unity 2019.4.39 and it works without any problem at least for now.. link: https://issuetracker.unity3d.com/issues/tooltips-are-not-shown-when-hovering-over-name-of-the-value-in-the-inspector

carsonwubc commented 2 years ago

I'm using 2020.3.25f1 but the issue still exists. I'm using Label and ShowIf for some fields but then the fields with Tooltip doesn't show the tooltips even that field doesn't use any NaughtyAttribute.

neohun commented 2 years ago

Well, it works for my version of the editor I have no idea why it does not work for you maybe use another version and check again.

maxsamarin commented 2 years ago

Got it to work with a simple solution, I hope this is the same problem you're having.

In PropertyUtility.cs, in function GUIContent GetLabel(SerializedProperty property)

Line 36. Replace "GUIContent label = new GUIContent(labelText);"

with: GUIContent label = new GUIContent(labelText, property.tooltip);

Now my tooltips are visible, if the script uses NaughtyAttributes (at least min and max value ones). Weird that the problem persisted even for field that didn't use NaughtyAttributes - it was enough for any field to use NaughtyAttributes for all fields' tooltips to become disabled