Tooltips Property Drawer

With the new PropertyDrawer feature in Unity, I figured I could finally create a decent inspector tooltip addon. So that’s what I did, and I’ve found it most useful, perhaps you might to.

I’ve attached it here:
1421314–74840–$Tooltips.zip (1.29 KB)
Just download and extract the folder into your project.

Example usage:

using System;
using UnityEngine;

[Serializable]
public class Effect {

    [Tooltip("Effect prefab, will be spawned as a child to the character GameObject.")]
    public GameObject prefab;

    [Tooltip("Duration of the effect.")]
    public float duration = 1f;

    [Tooltip("Effect action - applied to the character that is effected.")]
    public EffectAction effectAction;


    [Serializable]
    public class EffectAction
    {
        [Tooltip("Health added (or subtracted if below 0) to the Character.")]
        public int health = 0;
    }
}

Made and tested in Unity 4.3 - might not work on older versions.

Very handy. Thank you for this.

Thank you for posting this openly. It’s been a great help :slight_smile: What license are you distributing this under?

Cool! I fixed a bug in TooltipPropertyDrawer.cs, which causes errors in my editor, and tooltips to appear over edit fields with the wrong string:

public class TooltipPropertyDrawer : PropertyDrawer
{
    // (begin bug fix)
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent l)
    {
        GUIContent label = new GUIContent();
        label.image = l.image;
        label.text = l.text;
        // (end bug fix)
        label.tooltip = ((TooltipAttribute)attribute).text;