Hey,
Some standard Unity scripts shows additional information when you mouseover the variable in the inspector.
Does anyone know if there is a standard way of displaying this information on custom variables? (Both using public variables and/or Editor script)
See attached image on what i am trying to replicate.

As of Unity 4.5 or later just do this. The tooltip attribute is now built in.
public class SomeClass : MonoBehaviour
{
[Tooltip("This is a great tooltip")]
public int someVariable = 5;
}
GUIContent content = new GUIContent(“Text”, “Info Pop-up”);
int test = EditorGUILayout.IntField(content, test, GUILayout.Width(100f));
You can add tooltips easily with new Unity PropertyDrawers feature:
Assets/Scripts/TooltipAttribute.cs:
using UnityEngine;
public class TooltipAttribute : PropertyAttribute
{
public readonly string text;
public TooltipAttribute(string text)
{
this.text = text;
}
}
Assets/Editor/TooltipDrawer.cs:
using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(TooltipAttribute))]
public class TooltipDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
{
var atr = (TooltipAttribute) attribute;
var content = new GUIContent(label.text, atr.text);
EditorGUI.PropertyField(position, prop, content);
}
}
And use:
public class SomeClass : MonoBehaviour
{
[Tooltip("This is a great tooltip")]
public int someVariable = 5;
}
For that you would need to define a custom editor with a EditorGUILayout.PropertyField which is passed a GUIContent with the appropriate tooltip set.