Since Unity 2019.3, the properties to get fonts (e.g EditorStyles.standardFont) is changed from getting the value from a backing field to calling EditorResources.GetFont(FontDef.Style.[style]), and the backing field seems to be removed. Changes : UnityCsReference 2019.2 -> UnityCsReference 2019.3
Therefore these lines :
|
//EditorStyles static was pulled from s_Current which was populated from `EditorGUIUtility.GetBuiltinSkin` which we cannot interfere. |
|
//s_Current is internal and therefore we need to reflect to change the font. All other styles are accessible except the fonts. |
|
var eType = typeof(EditorStyles); |
|
var es = (EditorStyles)(eType.GetField("s_Current", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null)); |
|
eType.GetField("m_StandardFont", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(es, normalFont); |
|
eType.GetField("m_BoldFont", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(es, boldFont); |
|
eType.GetField("m_MiniFont", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(es, smallFont); |
|
eType.GetField("m_MiniBoldFont", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(es, smallBoldFont); |
will throw either NullPointerException or FieldNotFoundException and the code will no longer works.
Since Unity 2019.3, the properties to get fonts (e.g
EditorStyles.standardFont) is changed from getting the value from a backing field to callingEditorResources.GetFont(FontDef.Style.[style]), and the backing field seems to be removed. Changes : UnityCsReference 2019.2 -> UnityCsReference 2019.3Therefore these lines :
ModifyEditorStyle/Editor/ModifyEditorStyle.cs
Lines 318 to 325 in 1fa5ecb
will throw either
NullPointerExceptionorFieldNotFoundExceptionand the code will no longer works.