- Home /
Tooltips in Editor Windows?
Hey guys,
Do you know any alternative to the built-in Tooltip Atrribute which works with editor windows? The current is, as noted in the release notes, only for Inspectors, means only avaiable in MonoBehaviours. But I saw lots of other Editor Windows having Tooltips, so how would you implement it? Do I have to write my own code?
[Tooltip("Some Tooltip")]
Works in a MonoBehaviour, where 'Tooltip' basically describes the TooltipAttribute Class. However, in an Editor Window, theres no Tooltip rather than the TooltipAttribute, and using either of those results in errors:
Unexpected symbol `['
and all following code is 'unexpected'.
Do you know any common approach to this problem? Seneral
Answer by S_Darkwell · Mar 17, 2015 at 12:16 PM
You would actually use GUIContent to create a tooltip. Example:
[CustomEditor(typeof(Example))]
public class ExampleEditor : Editor
{
private void OnEnable()
{
Target = (Example) target;
}
public override void OnInspectorGUI()
{
Target.testFloat = EditorGUILayout.FloatField(new GUIContent("Test Float", "Here is a tooltip"), Target.testFloat);
}
}
It took me quite a while to find this myself.
Hope that helps!
It worked! Thanks so much, I felt like I was slam$$anonymous$$g my head against a wall all day trying to figure this out. :D
Glad I found this, I've been searching for over 40 $$anonymous$$utes!
This worked like a charm and helped me immensely, thanks! I recommend making the tooltip a variable if it can appear in multiple places, or if it's too long.
Your answer
Follow this Question
Related Questions
Is there a list of variable attributes for C#? 2 Answers
EditorWindow that changes properties of a custom gameObject 0 Answers
Reordable List in a window 1 Answer
How to avoid one button to be clicked when another button in footer overlaps it. 1 Answer
How do I stop new elements in a list/array from inheriting values from the last element? 1 Answer