I've made this script (ClassTooltipDrawer.cs), placed it in the Editor folder, aaaand... Nothing happens. Debug.Log doesn't trigger, extra LabelField isn't getting added, nothing.
[CustomEditor(typeof(MonoBehaviour))]
public class ClassTooltipDrawer : Editor
{
private string tooltipText = "test!";
private void OnEnable() // Seems like it isn't called
{
var attributes = target.GetType().GetCustomAttributes();
foreach (var attr in attributes)
{
if (attr is TooltipAttribute tooltip)
{
tooltipText = tooltip.tooltip;
break;
}
}
Debug.Log(tooltipText);
}
public override void OnInspectorGUI() //Seems like this is being ignored as well?
{
if(tooltipText.Length > 0)
EditorGUILayout.LabelField(tooltipText);
base.OnInspectorGUI();
}
}
I want to make use of the "tooltip" attribute and show it on class in Inspector (for now - as extra field, I didn't figured out how to do popup tooltips yet).