Adding tooltips to scripts in the inspector

A lot of the built in components have tool tips explaining what the various variable actually do. Is there a way to add something similar to my own scripts?

I know (or at least think) that I could write my own custom inspector, but I am hoping for some simpler (less time consuming) answer. Something like the ability to display comments on the same line as the variable declaration as a tool tip would be great. The ability to do something like:

var myVar;
myVar.tooltip="my tooltip";

Would be fine. If this ability does not exist in Unity I will simply make do.

A closely related question is if there is a way to make the variables display name in the inspector different than the actual variable (other than the capitalization and space injection Unity already does (which is great)) without using a custom inspector? The only reason I ask as part of this question is that I suspect that the answer to one question will be the same as the answer to the other.

I’ve made a package available in the Asset Store which lets you write tooltips in the code like this:

[Tooltip("This is a tooltip")]
public string tooltippedString;

Search the Asset Store for “Pimp my Editor” or go here

I would love to see something which creates it automatically from the remarks (such as adding @tooltip "blabla" to the remarks above a public member), however, as far as I know this is impossible right now. In order to do it today, what you would do is create a custom inspector and use GUIContent. The example at http://unity3d.com/support/documentation/ScriptReference/GUI-tooltip.html is for a GUI button (see the part: GUI.Button(new Rect(10, 10, 100, 20), new GUIContent("Click me", "This is the tooltip"));) but you can do the same with EditorGUI and EditorGUILayout elements (at least most of them...)

At least in Unity 4.6 you can use the following attribute:

[Tooltip("Health value between 0 and 100.")]
public int health = 0;

Check the documentation:

Hope this helps :slight_smile: