- Home /
How do I add a tool tip for class variables in the inspector?
When I mouse over default unity class' members (like those in Camera, Transform, etc), a nice little tool tip pops up explaining the purpose of the variable. I'd like to add this same kind of editor documentation to my stuff but can't seem to find info on how to add it. Any advice on this would be greatly appreciated, I'm using C# for my unity script, but any example would help me move in the right direction :)
Comment
Answer by karl_ · Jan 30, 2012 at 06:40 PM
You would use GUIContent. Example below:
using UnityEngine; using UnityEditor; using System.Collections; public class Test : EditorWindow {
[MenuItem("Window/Show Me")]
public static void init ()
{
((Test)ScriptableObject.CreateInstance(typeof(Test))).ShowUtility();
}
string stringVal = "";
public void OnGUI()
{
stringVal = EditorGUILayout.TextField(new GUIContent("String", "I'm a description"), stringVal);
}
}
Ah! I totally misread what he wanted. I kept thinking the monodevelop editor and not the game editor. :)