- Home /
Question by
TarTarGames · May 05, 2021 at 08:15 PM ·
c#fonts
Trouble with fonts.
Here's the problem. The answer's fields are filled with squares.! Alt text
Here is the code.
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
GUI.Box(position, GUIContent.none);
SerializedProperty isCorrectProp = property.FindPropertyRelative("_isCorrect");
Rect isCorrectRect = new Rect(position.x + 5, (position.y + position.height / 1.5f) - 7.5f, 15, 25);
isCorrectProp.boolValue = EditorGUI.Toggle(isCorrectRect, isCorrectProp.boolValue, EditorStyles.radioButton);
Rect labelRect = new Rect(position.x + isCorrectRect.width + 10, position.y, 85, 85);
GUIStyle labelStyle = new GUIStyle(EditorStyles.miniLabel)
{
alignment = TextAnchor.MiddleLeft
};
GUI.Label(labelRect, new GUIContent("Answer:", "Define an Answer."), labelStyle);
SerializedProperty infoProp = property.FindPropertyRelative("_info");
Rect infoRect = new Rect(labelRect.x + labelRect.width, (position.y + position.height / 2) - 10, position.width - 75, 70);
GUIStyle textAreaStyle = new GUIStyle(EditorStyles.textArea)
{
fontSize = 10,
fixedHeight = 15
};
textAreaStyle.font = Resources.Load<Font>("Fonts/Arial");
infoProp.stringValue = EditorGUI.TextArea(infoRect, infoProp.stringValue, textAreaStyle);
}
I've seen this solution before, but it doesn't work. https://answers.unity.com/questions/684199/how-do-i-change-my-font-in-code.html
Please give a recommendation to solve this problem. Thank you.
problem.png
(15.3 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613033339im_/https://answers.unity.com/themes/thub/images/avi.jpg)