unity3d - How can I make a GUI.Toggle font size and color to be bigger and in black like the example in the screenshot?
问题描述
The script is EditorWindow type:
What I did inside OnGUI:
void OnGUI()
{
GUIStyle myToggleStyle = new GUIStyle(GUI.skin.toggle);
myToggleStyle.fontSize = 14;
Font myFont = (Font)Resources.Load("Fonts/comic", typeof(Font));
myToggleStyle.font = myFont;
myToggleStyle.normal.textColor = Color.black;
GUI.Toggle(new Rect(5, 10, 200, 60), false, "Select All", myToggleStyle);
}
The screenshot show the result of my toggle at the top the "Select All" and under it the toggle how I want my one to be the same. A bit bigger but same color and font. If the bottom toggle size is 11 or 12 then my one should be 13 or 14. But as long as I make my toggle font size bigger the color is not the same as the bottom one and both are black.
The bottom one is created by EditorGUILayout.BeginToggleGroup and EditorGUILayout.EndToggleGroup but I want to make a single one not a group.
The main goal is to make a single toggle just like the bottom one by size and color.
解决方案
我认为您只需要将字体样式设置为粗体:
myToggleStyle.fontStyle = FontStyle.Bold;
推荐阅读
- javascript - 无法使用 Laravel Mix 访问 Vue 组件中的 js-cookie
- android - 为什么 Proguard 不会混淆某些包私有类?
- apache - 在 Apache 2.4 上使用带有反向代理的输出过滤器
- java - 如何在java项目中设置maven本地repo
- python - 如何在 Python 2.7 上使用没有控制台的子进程不断监听外部程序的输出
- javascript - 将 React 原生组件导出为 AAR android 库
- pdf - 通过google-apps-script将goole文档转换为pdf时如何摆脱不需要的额外页面?
- java - 使用提供的一组键和默认值创建 Map
- javascript - 没有为简单图表定义画布
- reactjs - 如何在高阶组件的 const 变量中声明通用 React 组件?