Skip to content

Commit fd5d91a

Browse files
author
Unity Technologies
committed
com.unity.textmeshpro@3.0.0
## [3.0.0] - 2020-06-30
1 parent ac5c841 commit fd5d91a

17 files changed

+246
-225
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
# Changelog
22
These are the release notes for the TextMesh Pro UPM package which was first introduced with Unity 2018.1. Please see the following link for the Release Notes for prior versions of TextMesh Pro. http://digitalnativestudios.com/forum/index.php?topic=1363.0
33

4+
## [3.0.0] - 2020-06-30
5+
## [2.1.0]
6+
## [1.5.0]
7+
### Changes
8+
- Added support to control if a text object is Maskable and affected by UI Mask components. The new setting is found in the Extra Settings section of the <TextMeshProUGUI> component inspector.
9+
- Fixed potential Null Reference Exception when trying to add characters and / or glyphs to a font asset via scripting and before it has been initialized or ReadFontAssetDefinition() has been called.
10+
- Fixed incorrect preferred width values when using alternative font weight font assets. Case #1255336
11+
- Enabling or disabling the Mesh Renderer of a <TextMeshPro> text object should now also mirror that state on any sub text object renderers as well.
12+
- Fixed <sprite> incorrect position when this sprite is the only character in the text and when the sprite asset face info has not been defined.
13+
- Fixed potential Null Reference Exception related to culling when entering play mode.
14+
- Added OnPreRenderText event delegate to allow potential modification of the text geometry before it is uploaded to the mesh and rendered.
15+
- Fixed missing warning when the requested character is missing from the font asset or any potential fallbacks. Case #1256879
16+
- Fixed potential issue with Underline and StrikeThrough when using alternative typeface. Case #1255336
17+
- Fixed potential errors in the Text StyleSheet Inspector when adding or removing Text Styles after resetting the asset. Case #1254602
18+
- Fixed text Margin property values not being draggable in the Extra Settings section of the text inspector. Case #1253447
19+
- It will no longer be possible to create Editor Presets for the TMP_FontAsset, TMP_SpriteAsset, TMP_StyleSheet, TMP_ColorGradient and TMP_Settings as these are persistent and runtime assets. Case #1251229
20+
421
## [3.0.0-preview.14] - 2020-06-08
522
## [2.1.0-preview.14]
623
## [1.5.0-preview.14]

Scripts/Editor/TMP_BaseEditorPanel.cs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,44 +1282,41 @@ protected void DrawMarginProperty(SerializedProperty property, GUIContent label)
12821282

12831283
float width = rect.width + 3;
12841284
pos0.width = EditorGUIUtility.labelWidth;
1285-
GUI.Label(pos0, label);
1285+
EditorGUI.PrefixLabel(pos0, label);
12861286

1287-
var vec = property.vector4Value;
1287+
Vector4 margins = property.vector4Value;
12881288

12891289
float widthB = width - EditorGUIUtility.labelWidth;
12901290
float fieldWidth = widthB / 4;
12911291
pos0.width = Mathf.Max(fieldWidth - 5, 45f);
12921292

12931293
// Labels
12941294
pos0.x = EditorGUIUtility.labelWidth + 15;
1295-
GUI.Label(pos0, k_LeftLabel);
1295+
margins.x = DrawMarginField(pos0, "Left", margins.x);
12961296

12971297
pos0.x += fieldWidth;
1298-
GUI.Label(pos0, k_TopLabel);
1298+
margins.y = DrawMarginField(pos0, "Top", margins.y);
12991299

13001300
pos0.x += fieldWidth;
1301-
GUI.Label(pos0, k_RightLabel);
1301+
margins.z = DrawMarginField(pos0, "Right", margins.z);
13021302

13031303
pos0.x += fieldWidth;
1304-
GUI.Label(pos0, k_BottomLabel);
1304+
margins.w = DrawMarginField(pos0, "Bottom", margins.w);
13051305

1306-
pos0.y += 18;
1306+
property.vector4Value = margins;
13071307

1308-
pos0.x = EditorGUIUtility.labelWidth + 15;
1309-
vec.x = EditorGUI.FloatField(pos0, GUIContent.none, vec.x);
1310-
1311-
pos0.x += fieldWidth;
1312-
vec.y = EditorGUI.FloatField(pos0, GUIContent.none, vec.y);
1313-
1314-
pos0.x += fieldWidth;
1315-
vec.z = EditorGUI.FloatField(pos0, GUIContent.none, vec.z);
1308+
EditorGUI.EndProperty();
1309+
}
13161310

1317-
pos0.x += fieldWidth;
1318-
vec.w = EditorGUI.FloatField(pos0, GUIContent.none, vec.w);
1311+
float DrawMarginField(Rect position, string label, float value)
1312+
{
1313+
int controlId = GUIUtility.GetControlID(FocusType.Keyboard, position);
1314+
EditorGUI.PrefixLabel(position, controlId, new GUIContent(label));
13191315

1320-
property.vector4Value = vec;
1316+
Rect dragZone = new Rect(position.x, position.y, position.width, position.height);
1317+
position.y += EditorGUIUtility.singleLineHeight;
13211318

1322-
EditorGUI.EndProperty();
1319+
return EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, position, dragZone, controlId, value, EditorGUI.kFloatFieldFormatString, EditorStyles.numberField, true);
13231320
}
13241321

13251322
protected void DrawPropertySlider(GUIContent label, SerializedProperty property)

Scripts/Editor/TMP_EditorPanelUI.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ namespace TMPro.EditorUtilities
99
public class TMP_EditorPanelUI : TMP_BaseEditorPanel
1010
{
1111
static readonly GUIContent k_RaycastTargetLabel = new GUIContent("Raycast Target", "Whether the text blocks raycasts from the Graphic Raycaster.");
12+
static readonly GUIContent k_MaskableLabel = new GUIContent("Maskable", "Determines if the text object will be affected by UI Mask.");
1213

1314
SerializedProperty m_RaycastTargetProp;
15+
private SerializedProperty m_MaskableProp;
1416

1517
protected override void OnEnable()
1618
{
1719
base.OnEnable();
1820
m_RaycastTargetProp = serializedObject.FindProperty("m_RaycastTarget");
21+
m_MaskableProp = serializedObject.FindProperty("m_Maskable");
1922
}
2023

2124
protected override void DrawExtraSettings()
@@ -40,6 +43,8 @@ protected override void DrawExtraSettings()
4043

4144
DrawRaycastTarget();
4245

46+
DrawMaskable();
47+
4348
DrawParsing();
4449

4550
DrawSpriteAsset();
@@ -69,6 +74,23 @@ protected void DrawRaycastTarget()
6974
}
7075
}
7176

77+
protected void DrawMaskable()
78+
{
79+
EditorGUI.BeginChangeCheck();
80+
EditorGUILayout.PropertyField(m_MaskableProp, k_MaskableLabel);
81+
if (EditorGUI.EndChangeCheck())
82+
{
83+
m_TextComponent.maskable = m_MaskableProp.boolValue;
84+
85+
// Change needs to propagate to the child sub objects.
86+
MaskableGraphic[] maskableGraphics = m_TextComponent.GetComponentsInChildren<MaskableGraphic>();
87+
for (int i = 1; i < maskableGraphics.Length; i++)
88+
maskableGraphics[i].maskable = m_MaskableProp.boolValue;
89+
90+
m_HavePropertiesChanged = true;
91+
}
92+
}
93+
7294
// Method to handle multi object selection
7395
protected override bool IsMixSelectionTypes()
7496
{
@@ -99,4 +121,4 @@ protected override void OnUndoRedo()
99121
}
100122
}
101123
}
102-
}
124+
}

Scripts/Editor/TMP_SpriteAssetEditor.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
using System.Collections.Generic;
66

77

8-
9-
108
namespace TMPro.EditorUtilities
119
{
1210

@@ -618,27 +616,28 @@ public override void OnInspectorGUI()
618616
#region Global Tools
619617
GUI.enabled = true;
620618
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
621-
EditorGUILayout.LabelField("Global Offsets & Scale", EditorStyles.boldLabel);
619+
rect = EditorGUILayout.GetControlRect(false, 40);
620+
621+
float width = (rect.width - 75f) / 4;
622+
EditorGUI.LabelField(rect, "Global Offsets & Scale", EditorStyles.boldLabel);
623+
622624

625+
rect.x += 70;
623626
bool old_ChangedState = GUI.changed;
624627

625628
GUI.changed = false;
626-
EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
627-
GUILayout.Space(25f);
628-
629-
m_xOffset = EditorGUILayout.FloatField(new GUIContent("OX:"), m_xOffset);
629+
m_xOffset = EditorGUI.FloatField(new Rect(rect.x + 5f + width * 0, rect.y + 20, width - 5f, 18), new GUIContent("OX:"), m_xOffset);
630630
if (GUI.changed) UpdateGlobalProperty("m_HorizontalBearingX", m_xOffset);
631631

632-
m_yOffset = EditorGUILayout.FloatField(new GUIContent("OY:"), m_yOffset);
632+
m_yOffset = EditorGUI.FloatField(new Rect(rect.x + 5f + width * 1, rect.y + 20, width - 5f, 18), new GUIContent("OY:"), m_yOffset);
633633
if (GUI.changed) UpdateGlobalProperty("m_HorizontalBearingY", m_yOffset);
634634

635-
m_xAdvance = EditorGUILayout.FloatField(new GUIContent("ADV."), m_xAdvance);
635+
m_xAdvance = EditorGUI.FloatField(new Rect(rect.x + 5f + width * 2, rect.y + 20, width - 5f, 18), new GUIContent("ADV."), m_xAdvance);
636636
if (GUI.changed) UpdateGlobalProperty("m_HorizontalAdvance", m_xAdvance);
637637

638-
m_scale = EditorGUILayout.FloatField(new GUIContent("SF."), m_scale);
638+
m_scale = EditorGUI.FloatField(new Rect(rect.x + 5f + width * 3, rect.y + 20, width - 5f, 18), new GUIContent("SF."), m_scale);
639639
if (GUI.changed) UpdateGlobalProperty("m_Scale", m_scale);
640640

641-
EditorGUILayout.EndHorizontal();
642641
EditorGUILayout.EndVertical();
643642
#endregion
644643

Scripts/Editor/TMP_StyleAssetMenu.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static void CreateTextMeshProObjectPerform()
3333
}
3434

3535

36-
string filePathWithName = AssetDatabase.GenerateUniqueAssetPath(filePath + "/TMP StyleSheet.asset");
36+
string filePathWithName = AssetDatabase.GenerateUniqueAssetPath(filePath + "/Text StyleSheet.asset");
3737

3838
//// Create new Style Sheet Asset.
3939
TMP_StyleSheet styleSheet = ScriptableObject.CreateInstance<TMP_StyleSheet>();
@@ -53,4 +53,4 @@ public static void CreateTextMeshProObjectPerform()
5353
}
5454
}
5555

56-
}
56+
}

Scripts/Editor/TMP_StyleSheetEditor.cs

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using UnityEngine;
1+
using System;
2+
using UnityEngine;
23
using UnityEditor;
34

45

@@ -25,7 +26,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2526
SerializedProperty closingDefinitionArray = property.FindPropertyRelative("m_ClosingTagArray");
2627

2728

28-
EditorGUIUtility.labelWidth = 90;
29+
EditorGUIUtility.labelWidth = 86;
2930
position.height = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
3031
float labelHeight = position.height + 2f;
3132

@@ -51,16 +52,16 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
5152
rect1.x += 65;
5253
rect1.width = position.width / 2 - 75;
5354
EditorGUI.PropertyField(rect1, hashCodeProperty, GUIContent.none);
54-
55+
5556
GUI.enabled = true;
5657

5758
// Text Tags
5859
EditorGUI.BeginChangeCheck();
59-
60+
6061
// Opening Tags
6162
position.y += labelHeight;
6263
GUI.Label(position, "Opening Tags");
63-
Rect textRect1 = new Rect(108, position.y, position.width - 86, 35);
64+
Rect textRect1 = new Rect(110, position.y, position.width - 86, 35);
6465
openingDefinitionProperty.stringValue = EditorGUI.TextArea(textRect1, openingDefinitionProperty.stringValue);
6566
if (EditorGUI.EndChangeCheck())
6667
{
@@ -82,22 +83,22 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
8283
// Closing Tags
8384
position.y += 38;
8485
GUI.Label(position, "Closing Tags");
85-
Rect textRect2 = new Rect(108, position.y, position.width - 86, 35);
86+
Rect textRect2 = new Rect(110, position.y, position.width - 86, 35);
8687
closingDefinitionProperty.stringValue = EditorGUI.TextArea(textRect2, closingDefinitionProperty.stringValue);
8788

8889
if (EditorGUI.EndChangeCheck())
8990
{
9091
// If any properties have changed, we need to update the Opening and Closing Arrays.
9192
int size = closingDefinitionProperty.stringValue.Length;
92-
93+
9394
// Adjust array size to match new string length.
9495
if (closingDefinitionArray.arraySize != size) closingDefinitionArray.arraySize = size;
95-
96+
9697
for (int i = 0; i < size; i++)
9798
{
9899
SerializedProperty element = closingDefinitionArray.GetArrayElementAtIndex(i);
99100
element.intValue = closingDefinitionProperty.stringValue[i];
100-
}
101+
}
101102
}
102103

103104
}
@@ -132,19 +133,19 @@ public override void OnInspectorGUI()
132133
serializedObject.Update();
133134

134135
m_IsStyleSheetDirty = false;
135-
int arraySize = m_StyleListProp.arraySize;
136+
int elementCount = m_StyleListProp.arraySize;
136137
int itemsPerPage = (Screen.height - 100) / 110;
137138

138-
if (arraySize > 0)
139+
if (elementCount > 0)
139140
{
140141
// Display each Style entry using the StyleDrawer PropertyDrawer.
141-
for (int i = itemsPerPage * m_Page; i < arraySize && i < itemsPerPage * (m_Page + 1); i++)
142+
for (int i = itemsPerPage * m_Page; i < elementCount && i < itemsPerPage * (m_Page + 1); i++)
142143
{
143144
// Define the start of the selection region of the element.
144145
Rect elementStartRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));
145146

146147
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
147-
148+
148149
SerializedProperty styleProperty = m_StyleListProp.GetArrayElementAtIndex(i);
149150
EditorGUI.BeginChangeCheck();
150151
EditorGUILayout.PropertyField(styleProperty);
@@ -153,7 +154,7 @@ public override void OnInspectorGUI()
153154
{
154155
//
155156
}
156-
157+
157158
// Define the end of the selection region of the element.
158159
Rect elementEndRegion = GUILayoutUtility.GetRect(0f, 0f, GUILayout.ExpandWidth(true));
159160

@@ -171,7 +172,7 @@ public override void OnInspectorGUI()
171172
GUIUtility.keyboardControl = 0;
172173
}
173174
}
174-
175+
175176
// Handle Selection Highlighting
176177
if (m_SelectedElement == i)
177178
TMP_EditorUtility.DrawBox(selectionArea, 2f, new Color32(40, 192, 255, 255));
@@ -193,7 +194,7 @@ public override void OnInspectorGUI()
193194

194195
// Move Style down.
195196
rect.x += rect.width;
196-
if (m_SelectedElement == arraySize - 1) { GUI.enabled = false; }
197+
if (m_SelectedElement == elementCount - 1) { GUI.enabled = false; }
197198
if (GUI.Button(rect, "Down"))
198199
{
199200
SwapStyleElements(m_SelectedElement, m_SelectedElement + 1);
@@ -205,7 +206,10 @@ public override void OnInspectorGUI()
205206
if (GUI.Button(rect, "+"))
206207
{
207208
int index = m_SelectedElement == -1 ? 0 : m_SelectedElement;
208-
209+
210+
if (index > elementCount)
211+
index = elementCount;
212+
209213
// Copy selected element
210214
m_StyleListProp.InsertArrayElementAtIndex(index);
211215

@@ -218,7 +222,7 @@ public override void OnInspectorGUI()
218222

219223
// Delete style
220224
rect.x += rect.width;
221-
if (m_SelectedElement == -1) GUI.enabled = false;
225+
if (m_SelectedElement == -1 || m_SelectedElement >= elementCount) GUI.enabled = false;
222226
if (GUI.Button(rect, "-"))
223227
{
224228
int index = m_SelectedElement == -1 ? 0 : m_SelectedElement;
@@ -250,19 +254,19 @@ public override void OnInspectorGUI()
250254
// PAGE COUNTER
251255
GUI.enabled = true;
252256
pagePos.x += pagePos.width;
253-
int totalPages = (int)(arraySize / (float)itemsPerPage + 0.999f);
257+
int totalPages = (int)(elementCount / (float)itemsPerPage + 0.999f);
254258
GUI.Label(pagePos, "Page " + (m_Page + 1) + " / " + totalPages, TMP_UIStyleManager.centeredLabel);
255259

256260
// Next Page
257261
pagePos.x += pagePos.width;
258-
if (itemsPerPage * (m_Page + 1) < arraySize) GUI.enabled = true;
262+
if (itemsPerPage * (m_Page + 1) < elementCount) GUI.enabled = true;
259263
else GUI.enabled = false;
260264

261265
if (GUI.Button(pagePos, "Next"))
262266
m_Page += 1 * shiftMultiplier;
263267

264268
// Clamp page range
265-
m_Page = Mathf.Clamp(m_Page, 0, arraySize / itemsPerPage);
269+
m_Page = Mathf.Clamp(m_Page, 0, elementCount / itemsPerPage);
266270

267271

268272
if (serializedObject.ApplyModifiedProperties())
@@ -276,11 +280,10 @@ public override void OnInspectorGUI()
276280
}
277281
}
278282

279-
// Clear selection if mouse event was not consumed.
283+
// Clear selection if mouse event was not consumed.
280284
GUI.enabled = true;
281285
if (currentEvent.type == EventType.MouseDown && currentEvent.button == 0)
282286
m_SelectedElement = -1;
283-
284287

285288
}
286289

0 commit comments

Comments
 (0)