I have a quite complex GUI in unity whit public override void OnInspectorGUI(). For all of my normal fieds I can add a tooltip with the header: Tooltip[("")] in the class itself. However, I need a dynamic dropdown list that needs to be updated with the number of elements of a list. I works great. Find the code of the custom editor script for the dropdown list:
string[] options = new string[movParamsListSize];
for (int i = 0; i < movParamsListSize; i++)
options[i] = i.ToString();
Rect r = EditorGUILayout.BeginHorizontal();
movStepToMoveTo.intValue = EditorGUILayout.Popup("movementStepToMoveTo",
movStepToMoveTo.intValue, options, EditorStyles.popup);
EditorGUILayout.EndHorizontal();
Find also a screenShot:
My problem is that I tried with all the overloaded functions of the EditorGUILayout.Popup() function (image below from the metadata) and cannot figure out how to add a tooltip when the mouse hovers to this control.
Any help is much apprecciated. Many thanks
Use the overload of EditorGUILayout.Popup
that takes a GUIContent
instead:
EditorGUILayout.Popup(new GUIContent("movementStepToMoveTo", "YOUR TOOLTIP HERE"), movStepToMoveTo.intValue, options);
Btw the EditorStyles.Popup
is redundant since this is the default for a Popup
;)
and also HorizontalGroup
is quite redundant here. You have only one control anyway.