SerializedProperty is empty with [Tooltip] attribute

Maybe Im missing something here, but Im having problems regarding tooltips:

I have a class with several properties, which each have a [Tooltip(“”)] attribute assigned to them. However, when I get the SerializedProperty’s .tooltip member, it is empty. Is this a bug or am I doing something wrong? Running Unity 4.6.1f1 here

here is my code:

private void DrawPropertyField(Rect position, SerializedProperty property, GUIContent label)
{
   GUIContent label = new GUIContent(property.name, property.tooltip);
   Rect propertyRect = position;
   propertyRect.width -= labelWidth;
   propertyRect.x += labelWidth;
   EditorGUI.PrefixLabel(position, label);
   EditorGUI.PropertyField(propertyRect, property, GUIContent.none);
}

Also, for people who are wondering why Im not just using PropertyField, the labels are eating away too much space for my desire, so I am overwriting it this way. If there is another better way please let me know.

Anyone has got any idea?

Nope, same problem here, seems broken. This and other bugs/flaws have made my initial foray into PropertyDrawers very disappointing.

Seems to be still broken in 5.2 =(

My repro case:

“My” custom class:

using System;
using UnityEngine;

[Serializable]
public struct Test
{
    [SerializeField]
    private int intValue;
}

MonoBehaviour with field of the Test type:

using UnityEngine;

public class Tooltips : MonoBehaviour
{
    [Tooltip("I'm invisible tooltip :(")]
    public Test test;

    [Tooltip("I'm visible tooltip :)")]
    public Vector3 vector;
}

The drawer itself:

using UnityEngine;
using UnityEditor;

[CustomPropertyDrawer(typeof(Test))]
public class TestDrawer : PropertyDrawer
{
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        SerializedProperty intValue = property.FindPropertyRelative("intValue");
        EditorGUI.PropertyField(position, intValue, label);
    }
}

Both property.tooltip and label.tooltip are empty for me.

Sent a bug report (case 728880).

Or I missing something here too? :eyes:

Good news (hopefully) - QA confirmed it’s a bug and it was reproduced on the 5.1, 5.2 and 5.3 Unity versions!

Thanks for letting us know! I hope we will see a patch fix for this soon

3 years later, still the bug present.

Simple workaround to restore the original tooltip to the label: on your PropertyDrawer OnGUI method, add these lines:

var tooltipAttribute = fieldInfo.GetAttribute<TooltipAttribute>();
label.tooltip = tooltipAttribute != null ? tooltipAttribute.tooltip : "";

Found the right answer here.

Looks like the original issues is simply marked as “won fix”, without any detail.

1 Like

Sad to hear that! My case where I reported it is having state Closed (case 728880).

It’s worth trying submitting a new bug report, perhaps there is a regression or fix didn’t get into the main trunk.

I can confirm that this bug is still here :(. I will be using the workaround for now :slight_smile:

The fix is planned for 2019.4, 2020.2, 2021.1 and is currently in review. Lets see when it lands. I guess it’s likely it will in the next weeks. :slight_smile:

3 Likes

I fixed it the other day :smile: We had a bug report about our Localization property drawers not displaying tooltips, after investigation I discovered it was an issue for all PropertyDrawers. The fix was actually really simple, the tooltip data is in the Property handler code, we just didn’t pass it through. The original bug was closed as low priority in 2017.
Moral of the story, keep making bug reports, it brings the old issues back into light so we can revaluate them.

7 Likes

Thank you Karl! While you’re at the tooltip, could you please remove the restriction from the TooltipAttribute that it can be used on fields only? This should be a trivial change without any risk I assume.

I would like to use the built-in TooltipAttribute to display them as “class comments”, see here .

Took some time and fix was similar to what I had expected, but at least I am glad that this has been fixed, thank you!

1 Like

Ill bring it up with the Editor team but this is more of a feature request than a bug fix so its harder to justify.

2 Likes

Thanks Karl! Would be great if “low priority” wasnt a valid reason for closing an issue. Could that be reviewed? Takes time and dedication to open an issue, is a pitty to have them closed merely for bureaucratic reasons.

2 Likes

Yeah I’m not really sure about that justification but it was 4 years ago so a lot has changed in our bug handling since then.

1 Like

Karl, do you now what releases are expected to include your fix? My current project is still using Unity 2018.4.30. Is your fix expected to be included in 2018 LTS?

I only requested as far as 2019.4 as 2018.4 only really accepts high priority bugs now. I’ll create a 2018.4 request and see if it gets accepted.

1 Like

Is this fixed in 2020.3 as well? I assumed as much because it’s fixed for 2020.2.X but my Custom Inspector still get’s empty strings for properties that have a tooltip

It has been fixed in Unity 2019.4.24f1 now as well :slight_smile:

1 Like