当鼠标悬停在一个统一的EditorGUILayout.Popup()上时,无法添加显示的工具提示

时间:2019-11-15 15:03:08

标签: c# unity3d unity-editor

我有一个相当复杂的GUI,但在公共方面重写void OnInspectorGUI()。 对于我所有的正常情况,我可以在类本身中添加带有标题的工具提示:Tooltip [(“”)]]。 但是,我需要一个动态下拉列表,该列表需要使用列表中的元素数量进行更新。 我的工作很棒。在下拉列表中找到自定义编辑器脚本的代码:

        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();

还找到一个屏幕截图:

enter image description here

我的问题是,我尝试使用EditorGUILayout.Popup()函数的所有重载函数(下图来自元数据),并且无法弄清楚当鼠标悬停在此控件上时如何添加工具提示。

enter image description here

非常感谢任何帮助。非常感谢

1 个答案:

答案 0 :(得分:1)

使用EditorGUILayout.PopupGUIContent重载代替:

EditorGUILayout.Popup(new GUIContent("movementStepToMoveTo", "YOUR TOOLTIP HERE"), movStepToMoveTo.intValue, options);

EditorStyles.Popup是多余的,因为这是Popup的默认设置;)

HorizontalGroup在这里也是多余的。无论如何,您只有一个控件。

相关问题