public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { SerializedProperty prop_FirstAdjustmentRecord = property.FindPropertyRelative("m_FirstAdjustmentRecord"); SerializedProperty prop_SecondAdjustmentRecord = property.FindPropertyRelative("m_SecondAdjustmentRecord"); SerializedProperty prop_FirstGlyphIndex = prop_FirstAdjustmentRecord.FindPropertyRelative("m_GlyphIndex"); SerializedProperty prop_FirstGlyphValueRecord = prop_FirstAdjustmentRecord.FindPropertyRelative("m_GlyphValueRecord"); SerializedProperty prop_SecondGlyphIndex = prop_SecondAdjustmentRecord.FindPropertyRelative("m_GlyphIndex"); SerializedProperty prop_SecondGlyphValueRecord = prop_SecondAdjustmentRecord.FindPropertyRelative("m_GlyphValueRecord"); SerializedProperty prop_FontFeatureLookupFlags = property.FindPropertyRelative("m_FeatureLookupFlags"); position.yMin += 2; float width = position.width / 2; float padding = 5.0f; Rect rect; isEditingEnabled = GUI.enabled; isSelectable = label.text == "Selectable" ? true : false; if (isSelectable) { GUILayoutUtility.GetRect(position.width, 75); } else { GUILayoutUtility.GetRect(position.width, 55); } GUIStyle style = new GUIStyle(EditorStyles.label); style.richText = true; // First Glyph GUI.enabled = isEditingEnabled; if (isSelectable) { rect = new Rect(position.x + 70, position.y, position.width, 49); float labelWidth = GUI.skin.label.CalcSize(new GUIContent("ID: " + prop_FirstGlyphIndex.intValue)).x; EditorGUI.LabelField(new Rect(position.x + (64 - labelWidth) / 2, position.y + 60, 64f, 18f), new GUIContent("ID: <color=#FFFF80>" + prop_FirstGlyphIndex.intValue + "</color>"), style); GUI.enabled = isEditingEnabled; EditorGUIUtility.labelWidth = 30f; rect = new Rect(position.x + 70, position.y + 10, (width - 70) - padding, 18); EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_XPlacement"), new GUIContent("OX:")); rect.y += 20; EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_YPlacement"), new GUIContent("OY:")); rect.y += 20; EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_XAdvance"), new GUIContent("AX:")); //rect.y += 20; //EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_YAdvance"), new GUIContent("AY:")); DrawGlyph((uint)prop_FirstGlyphIndex.intValue, new Rect(position.x, position.y, position.width, position.height), property); } else { rect = new Rect(position.x, position.y, width / 2 * 0.8f - padding, 18); EditorGUIUtility.labelWidth = 40f; // First Character Lookup GUI.SetNextControlName("FirstCharacterField"); EditorGUI.BeginChangeCheck(); string firstCharacter = EditorGUI.TextField(rect, s_CharacterTextFieldLabel, m_FirstCharacter); if (GUI.GetNameOfFocusedControl() == "FirstCharacterField") { if (ValidateInput(firstCharacter)) { //Debug.Log("1st Unicode value: [" + firstCharacter + "]"); uint unicode = GetUnicodeCharacter(firstCharacter); // Lookup glyph index TMP_SerializedPropertyHolder propertyHolder = property.serializedObject.targetObject as TMP_SerializedPropertyHolder; TMP_FontAsset fontAsset = propertyHolder.fontAsset; if (fontAsset != null) { prop_FirstGlyphIndex.intValue = (int)fontAsset.GetGlyphIndex(unicode); propertyHolder.firstCharacter = unicode; } } } if (EditorGUI.EndChangeCheck()) { m_FirstCharacter = firstCharacter; } // First Glyph Index rect.x += width / 2 * 0.8f; EditorGUIUtility.labelWidth = 25f; EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(rect, prop_FirstGlyphIndex, new GUIContent("ID:")); if (EditorGUI.EndChangeCheck()) { } GUI.enabled = isEditingEnabled; EditorGUIUtility.labelWidth = 25f; rect = new Rect(position.x, position.y + 20, width * 0.5f - padding, 18); EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_XPlacement"), new GUIContent("OX")); rect.x += width * 0.5f; EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_YPlacement"), new GUIContent("OY")); rect.x = position.x; rect.y += 20; EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_XAdvance"), new GUIContent("AX")); //rect.x += width * 0.5f; //EditorGUI.PropertyField(rect, prop_FirstGlyphAdjustment.FindPropertyRelative("m_YAdvance"), new GUIContent("AY")); } // Second Glyph GUI.enabled = isEditingEnabled; if (isSelectable) { float labelWidth = GUI.skin.label.CalcSize(new GUIContent("ID: " + prop_SecondGlyphIndex.intValue)).x; EditorGUI.LabelField(new Rect(position.width / 2 + 20 + (64 - labelWidth) / 2, position.y + 60, 64f, 18f), new GUIContent("ID: <color=#FFFF80>" + prop_SecondGlyphIndex.intValue + "</color>"), style); GUI.enabled = isEditingEnabled; EditorGUIUtility.labelWidth = 30f; rect = new Rect(position.width / 2 + 20 + 70, position.y + 10, (width - 70) - padding, 18); EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_XPlacement"), new GUIContent("OX:")); rect.y += 20; EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_YPlacement"), new GUIContent("OY:")); rect.y += 20; EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_XAdvance"), new GUIContent("AX:")); //rect.y += 20; //EditorGUI.PropertyField(rect, prop_SecondGlyphAdjustment.FindPropertyRelative("m_YAdvance"), new GUIContent("AY")); DrawGlyph((uint)prop_SecondGlyphIndex.intValue, new Rect(position.width / 2 + 20, position.y, position.width, position.height), property); } else { rect = new Rect(position.width / 2 + 20, position.y, width / 2 * 0.8f - padding, 18); EditorGUIUtility.labelWidth = 40f; // Second Character Lookup GUI.SetNextControlName("SecondCharacterField"); EditorGUI.BeginChangeCheck(); string secondCharacter = EditorGUI.TextField(rect, s_CharacterTextFieldLabel, m_SecondCharacter); if (GUI.GetNameOfFocusedControl() == "SecondCharacterField") { if (ValidateInput(secondCharacter)) { //Debug.Log("2nd Unicode value: [" + secondCharacter + "]"); uint unicode = GetUnicodeCharacter(secondCharacter); // Lookup glyph index TMP_SerializedPropertyHolder propertyHolder = property.serializedObject.targetObject as TMP_SerializedPropertyHolder; TMP_FontAsset fontAsset = propertyHolder.fontAsset; if (fontAsset != null) { prop_SecondGlyphIndex.intValue = (int)fontAsset.GetGlyphIndex(unicode); propertyHolder.secondCharacter = unicode; } } } if (EditorGUI.EndChangeCheck()) { m_SecondCharacter = secondCharacter; } // Second Glyph Index rect.x += width / 2 * 0.8f; EditorGUIUtility.labelWidth = 25f; EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(rect, prop_SecondGlyphIndex, new GUIContent("ID:")); if (EditorGUI.EndChangeCheck()) { } GUI.enabled = isEditingEnabled; EditorGUIUtility.labelWidth = 25f; rect = new Rect(position.width / 2 + 20, position.y + 20, width * 0.5f - padding, 18); EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_XPlacement"), new GUIContent("OX")); rect.x += width * 0.5f; EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_YPlacement"), new GUIContent("OY")); rect.x = position.width / 2 + 20; rect.y += 20; EditorGUI.PropertyField(rect, prop_SecondGlyphValueRecord.FindPropertyRelative("m_XAdvance"), new GUIContent("AX")); //rect.x += width * 0.5f; //EditorGUI.PropertyField(rect, prop_SecondGlyphAdjustment.FindPropertyRelative("m_YAdvance"), new GUIContent("AY")); } // Font Feature Lookup Flags if (isSelectable) { EditorGUIUtility.labelWidth = 55f; rect.x = position.width - 255; rect.y += 23; rect.width = 270; // width - 70 - padding; FontFeatureLookupFlags flags = (FontFeatureLookupFlags)prop_FontFeatureLookupFlags.intValue; EditorGUI.BeginChangeCheck(); flags = (FontFeatureLookupFlags)EditorGUI.EnumFlagsField(rect, new GUIContent("Options:"), flags); if (EditorGUI.EndChangeCheck()) { prop_FontFeatureLookupFlags.intValue = (int)flags; } } }