Unity Editor GUI,更改EditorGUILayout.Toggle的标签宽度

Car*_*arl 2 unity-game-engine

我找不到增加 EditorGUILayout.Toggle 标签宽度的方法。这是我的代码,它不执行任何操作,Unity 会剪辑文本并将其剪短。

GUILayoutOption[] options = new GUILayoutOption[] {
GUILayout.Width(400.0f), 
GUILayout.MinWidth(250.0f), 
GUILayout.ExpandWidth(true) 
};
MyBoolValue = EditorGUILayout.Toggle("My Long Description Text Here", MyBoolValue, options);
Run Code Online (Sandbox Code Playgroud)

我确实尝试将切换按钮包裹起来

 EditorGUILayout.BeginHorizontal();
 EditorGUILayout.EndHorizontal();
Run Code Online (Sandbox Code Playgroud)

但它也没有做任何事情。如何删除文本中的剪裁?

Ben*_*bin 6

EditorGUIUtility.labelWidth在执行您的操作之前进行设置Toggle,然后将其恢复为原始值,这样您就不会弄乱任何后续控件。

float originalValue = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 400;   
MyBoolValue = EditorGUILayout.Toggle("My Long Description Text Here", MyBoolValue);
EditorGUIUtility.labelWidth = originalValue;
Run Code Online (Sandbox Code Playgroud)