Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.5.0-preview.10] - 2020-04-21
## [2.1.0-preview.10]
## [3.0.0-preview.10]
### Changes
- Revised caching of Preferred Width and Height to further reduce the amount of time it has to be recomputed when using a complex structure of Layout components.
- Fixed potential issue when using Text Overflow Ellipsis and Truncate modes when the text contains characters using superscript, subscript or using the <voffset> tag.
- Revised culling of text objects when using a RectMask2D where the bounds of the text geometry instead of the RectTransform define the culling rect.
- Added HDR support to material preset colors.
- Fixed various formatting issues in this ChangeLog.
- Added the ability to define a unicode value for a missing sprite character in the TMP Settings.
- Added support for displaying a missing sprite character when the requested sprite character is not present in the sprite asset or potential fallback(s). This new functionality is only available when trying to reference a sprite by name.
- Sprite Characters will now have a default Unicode value of 0xFFFE (Private NonCharacter) instead of a Unicode value of 0x0 (default unicode value for missing character).
- Using the sprite asset context menu option "Update Sprite Asset" will now remap sprite characters with unicode value of 0x0 to 0xFFFE in addition to its currently functionality.
- Updating TMP Essential Resources via the "Window - TextMeshPro - Import TMP Essential Resources" menu option will no longer override existing TMP Settings.
- Minor optimization where SDF Scale on some text objects could be unnecessarily updated due to floating point rounding errors in their lossy scale. Case #1230799
- Fixed minor issue where text objects created before importing the required TMP Essential Resources would have no default text.
- Improvements to line breaking for CJK and mixed Latin and CJK characters. See the following [forum post](https://forum.unity.com/threads/tmp-bug.852733/#post-5688274) for more details.
- Fixed potential NullReferenceException that could occur in the TMP InputField on some platforms if the InputSystem reference is null. Case #1232433
- Added small padding to bitmap character geometry to prevent potential clipping.
- Added optimization to ignore very small RectTransform pivot changes that are usually the result of rounding errors when using Layout Components. Case #1237700
- Sorting Layer ID and Sorting Order properties located in the Extra Settings of <TextMeshPro> text objects will now serialized when creating Editor Presets. Case #1215750
- TextMeshProUGUI sub text objects will now be set as first sibling of their parent to prevent them from being rendered over other non text object child in the scene hierarchy.
- Fixed text objects becoming visible when set to empty or null as a result of a scale change. Case #1238408
- Fixed useMaxVisibleDescender property now getting set properly via scripting. Case #1218526
- Fixed SortingLayerID and SortingOrder not getting set correctly when multiple <TextMeshPro> objects are selected. Case #1171272
- Fixed default settings getting applied to disabled text objects in the scene hierarchy whose text property was set to null. Case #1151621
- Fixed mouse cursor flickering when hovering the Text Input Box of a text prefab with RTL enabled. Case #1206395
  • Loading branch information
Unity Technologies committed Apr 20, 2020
1 parent f6d1bcd commit 4700481
Show file tree
Hide file tree
Showing 41 changed files with 1,672 additions and 1,342 deletions.
58 changes: 43 additions & 15 deletions CHANGELOG.md

Large diffs are not rendered by default.

Binary file modified Package Resources/TMP Essential Resources.unitypackage
Binary file not shown.
Binary file modified Package Resources/TMP Examples & Extras.unitypackage
Binary file not shown.
6 changes: 3 additions & 3 deletions Scripts/Editor/GlyphMetricsPropertyDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
// We get Rect since a valid position may not be provided by the caller.
Rect rect = new Rect(position.x, position.y, position.width, 49);

EditorGUI.LabelField(rect, new GUIContent("Glyph Metrics"));
EditorGUI.LabelField(new Rect(rect.x, rect.y - 2.5f, rect.width, 18), new GUIContent("Glyph Metrics"));

EditorGUIUtility.labelWidth = 30f;
EditorGUIUtility.fieldWidth = 10f;
EditorGUIUtility.labelWidth = 50f;
EditorGUIUtility.fieldWidth = 15f;

//GUI.enabled = false;
float width = (rect.width - 75f) / 2;
Expand Down
6 changes: 3 additions & 3 deletions Scripts/Editor/GlyphRectPropertyDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten

// We get Rect since a valid position may not be provided by the caller.
Rect rect = new Rect(position.x, position.y, position.width, 49);
EditorGUI.LabelField(rect, new GUIContent("Glyph Rect"));
EditorGUI.LabelField(new Rect(rect.x, rect.y - 2.5f, rect.width, 18), new GUIContent("Glyph Rect"));

EditorGUIUtility.labelWidth = 30f;
EditorGUIUtility.fieldWidth = 10f;
EditorGUIUtility.labelWidth = 50f;
EditorGUIUtility.fieldWidth = 20f;

//GUI.enabled = false;
float width = (rect.width - 75f) / 4;
Expand Down
147 changes: 75 additions & 72 deletions Scripts/Editor/TMP_BaseEditorPanel.cs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Scripts/Editor/TMP_BaseShaderGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
protected bool BeginPanel(string panel, bool expanded)
{
EditorGUI.indentLevel = 0;

EditorGUILayout.BeginVertical(EditorStyles.helpBox);
Rect r = EditorGUI.IndentedRect(GUILayoutUtility.GetRect(20, 18));
r.x += 20;
Expand All @@ -199,7 +199,7 @@ protected bool BeginPanel(string panel, bool expanded)
protected bool BeginPanel(string panel, ShaderFeature feature, bool expanded, bool readState = true)
{
EditorGUI.indentLevel = 0;

if (readState)
{
feature.ReadState(m_Material);
Expand Down Expand Up @@ -286,7 +286,7 @@ void DoTexture(string name, string label, System.Type type, bool withTilingOffse
{
MaterialProperty property = FindProperty(name, m_Properties);
m_Editor.BeginAnimatedCheck(Rect.zero, property);

Rect rect = EditorGUILayout.GetControlRect(true, 60f);
float totalWidth = rect.width;
rect.width = EditorGUIUtility.labelWidth + 60f;
Expand Down Expand Up @@ -414,7 +414,7 @@ protected void DoColor(string name, string label)
{
MaterialProperty property = BeginProperty(name);
s_TempLabel.text = label;
Color value = EditorGUI.ColorField(EditorGUILayout.GetControlRect(), s_TempLabel, property.colorValue);
Color value = EditorGUI.ColorField(EditorGUILayout.GetControlRect(), s_TempLabel, property.colorValue, false, true, true);
if (EndProperty())
{
property.colorValue = value;
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Editor/TMP_CharacterPropertyDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
if (elementIndex == -1)
prop_GlyphIndex.intValue = currentGlyphIndex;
else
fontAsset.m_IsFontAssetLookupTablesDirty = true;
fontAsset.IsFontAssetLookupTablesDirty = true;
}

int glyphIndex = prop_GlyphIndex.intValue;
Expand Down
70 changes: 48 additions & 22 deletions Scripts/Editor/TMP_EditorPanel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using UnityEngine;
using UnityEditor;
using UnityEditor.Presets;

namespace TMPro.EditorUtilities
{
Expand All @@ -11,22 +12,29 @@ public class TMP_EditorPanel : TMP_BaseEditorPanel
static readonly GUIContent k_OrderInLayerLabel = new GUIContent("Order in Layer", "Renderer's order within a sorting layer.");
static readonly GUIContent k_OrthographicLabel = new GUIContent("Orthographic Mode", "Should be enabled when using an orthographic camera. Instructs the shader to not perform any perspective correction.");
static readonly GUIContent k_VolumetricLabel = new GUIContent("Volumetric Setup", "Use cubes rather than quads to render the text. Allows for volumetric rendering when combined with a compatible shader.");


private static string[] k_SortingLayerNames;
bool IsPreset;

SerializedProperty m_IsVolumetricTextProp;

SerializedProperty m_IsOrthographicProp;

Renderer m_Renderer;

protected override void OnEnable()
{
base.OnEnable();

// Determine if the inspected object is a Preset
IsPreset = (int)(target as Component).gameObject.hideFlags == 93;

m_IsOrthographicProp = serializedObject.FindProperty("m_isOrthographic");

m_IsVolumetricTextProp = serializedObject.FindProperty("m_isVolumetricText");

m_Renderer = m_TextComponent.GetComponent<Renderer>();

// Populate Sorting Layer Names
k_SortingLayerNames = SortingLayerHelper.sortingLayerNames;
}

protected override void DrawExtraSettings()
Expand All @@ -51,7 +59,7 @@ protected override void DrawExtraSettings()
DrawIsTextObjectScaleStatic();

DrawOrthographicMode();

DrawRichText();

DrawParsing();
Expand All @@ -76,33 +84,29 @@ protected void DrawSortingLayer()

EditorGUI.BeginChangeCheck();

// SORTING LAYERS
var sortingLayerNames = SortingLayerHelper.sortingLayerNames;

var textComponent = (TextMeshPro)m_TextComponent;
TextMeshPro textComponent = (TextMeshPro)m_TextComponent;

// Look up the layer name using the current layer ID
string oldName = SortingLayerHelper.GetSortingLayerNameFromID(textComponent.sortingLayerID);
string oldName = IsPreset ? SortingLayer.IDToName(textComponent._SortingLayerID) : SortingLayer.IDToName(textComponent.sortingLayerID);

// Use the name to look up our array index into the names list
int oldLayerIndex = System.Array.IndexOf(sortingLayerNames, oldName);
int oldLayerIndex = System.Array.IndexOf(k_SortingLayerNames, oldName);

// Show the pop-up for the names
EditorGUIUtility.fieldWidth = 0f;
int newLayerIndex = EditorGUILayout.Popup(k_SortingLayerLabel, oldLayerIndex, sortingLayerNames);
int newLayerIndex = EditorGUILayout.Popup(k_SortingLayerLabel, oldLayerIndex, k_SortingLayerNames);

// If the index changes, look up the ID for the new index to store as the new ID
if (newLayerIndex != oldLayerIndex)
{
textComponent.sortingLayerID = SortingLayerHelper.GetSortingLayerIDForIndex(newLayerIndex);
}
UpdateTargetsSortingLayerID(SortingLayer.NameToID(k_SortingLayerNames[newLayerIndex]));

// Get value from internal property if target is a Preset otherwise from the public property
int oldSortingOrder = IsPreset ? textComponent._SortingOrder : textComponent.sortingOrder;

int newSortingLayerOrder = EditorGUILayout.IntField(k_OrderInLayerLabel, oldSortingOrder);

// Expose the manual sorting order
int newSortingLayerOrder = EditorGUILayout.IntField(k_OrderInLayerLabel, textComponent.sortingOrder);
if (newSortingLayerOrder != textComponent.sortingOrder)
{
textComponent.sortingOrder = newSortingLayerOrder;
}
UpdateTargetsSortingOrder(newSortingLayerOrder);

if (EditorGUI.EndChangeCheck())
m_HavePropertiesChanged = true;
Expand Down Expand Up @@ -161,5 +165,27 @@ protected override void OnUndoRedo()
}
}
}

void UpdateTargetsSortingLayerID(int sortingLayerID)
{
for (int i = 0; i < targets.Length; i++)
{
var textComponent = (TextMeshPro)targets[i];

if (textComponent != null)
textComponent.sortingLayerID = sortingLayerID;
}
}

void UpdateTargetsSortingOrder(int sortingOrder)
{
for (int i = 0; i < targets.Length; i++)
{
var textComponent = (TextMeshPro)targets[i];

if (textComponent != null)
textComponent.sortingOrder = sortingOrder;
}
}
}
}
}
2 changes: 1 addition & 1 deletion Scripts/Editor/TMP_FontAssetEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ public override void OnInspectorGUI()
if (m_DisplayDestructiveChangeWarning == false)
TMPro_EventManager.ON_FONT_PROPERTY_CHANGED(true, m_fontAsset);

if (m_fontAsset.m_IsFontAssetLookupTablesDirty || evt_cmd == k_UndoRedo)
if (m_fontAsset.IsFontAssetLookupTablesDirty || evt_cmd == k_UndoRedo)
m_fontAsset.ReadFontAssetDefinition();

isAssetDirty = false;
Expand Down
54 changes: 43 additions & 11 deletions Scripts/Editor/TMP_PackageUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void ShowConverterWindow()
};

/// <summary>
///
///
/// </summary>
struct AssetModificationRecord
{
Expand Down Expand Up @@ -234,7 +234,7 @@ void SetEditorWindowSize()


/// <summary>
///
///
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
Expand Down Expand Up @@ -402,7 +402,7 @@ static void ScanProjectFileAsync(AssetFileRecord fileRecord)


/// <summary>
///
///
/// </summary>
private static void ResetScanProcess()
{
Expand All @@ -415,7 +415,7 @@ private static void ResetScanProcess()


/// <summary>
///
///
/// </summary>
private static void UpdateProjectFiles()
{
Expand Down Expand Up @@ -488,7 +488,7 @@ void OnEnable()
private void OnGUI()
{
}
Expand Down Expand Up @@ -535,7 +535,7 @@ struct AssetModificationRecord
}

/// <summary>
///
///
/// </summary>
[MenuItem("Window/TextMeshPro/Import TMP Essential Resources", false, 2050)]
public static void ImportProjectResourcesMenu()
Expand All @@ -545,7 +545,7 @@ public static void ImportProjectResourcesMenu()


/// <summary>
///
///
/// </summary>
[MenuItem("Window/TextMeshPro/Import TMP Examples and Extras", false, 2051)]
public static void ImportExamplesContentMenu()
Expand All @@ -562,24 +562,56 @@ private static void GetVersionInfo()


/// <summary>
///
///
/// </summary>
private static void ImportExamplesAndExtras()
{
string packageFullPath = EditorUtilities.TMP_EditorUtility.packageFullPath;
string packageFullPath = TMP_EditorUtility.packageFullPath;

AssetDatabase.ImportPackage(packageFullPath + "/Package Resources/TMP Examples & Extras.unitypackage", true);
}

private static string k_SettingsFilePath;
private static byte[] k_SettingsBackup;

/// <summary>
///
///
/// </summary>
private static void ImportEssentialResources()
{
string packageFullPath = EditorUtilities.TMP_EditorUtility.packageFullPath;
// Check if the TMP Settings asset is already present in the project.
string[] settings = AssetDatabase.FindAssets("t:TMP_Settings");

if (settings.Length > 0)
{
// Save assets just in case the TMP Setting were modified before import.
AssetDatabase.SaveAssets();

// Copy existing TMP Settings asset to a byte[]
k_SettingsFilePath = AssetDatabase.GUIDToAssetPath(settings[0]);
k_SettingsBackup = File.ReadAllBytes(k_SettingsFilePath);

RegisterResourceImportCallback();
}

string packageFullPath = TMP_EditorUtility.packageFullPath;

AssetDatabase.ImportPackage(packageFullPath + "/Package Resources/TMP Essential Resources.unitypackage", true);
}

private static void RegisterResourceImportCallback()
{
AssetDatabase.importPackageCompleted += ImportCallback;
}

private static void ImportCallback(string packageName)
{
// Restore backup of TMP Settings from byte[]
File.WriteAllBytes(k_SettingsFilePath, k_SettingsBackup);

AssetDatabase.Refresh();

AssetDatabase.importPackageCompleted -= ImportCallback;
}
}
}
11 changes: 9 additions & 2 deletions Scripts/Editor/TMP_SettingsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ internal class Styles
public static readonly GUIContent getFontFeaturesAtRuntime = new GUIContent("Get Font Features at Runtime", "Determines if Glyph Adjustment Data will be retrieved from font files at runtime when new characters and glyphs are added to font assets.");
public static readonly GUIContent dynamicAtlasTextureGroup = new GUIContent("Dynamic Atlas Texture Group");

public static readonly GUIContent missingGlyphLabel = new GUIContent("Replacement Character", "The character to be displayed when the requested character is not found in any font asset or fallbacks.");
public static readonly GUIContent missingGlyphLabel = new GUIContent("Missing Character Unicode", "The character to be displayed when the requested character is not found in any font asset or fallbacks.");
public static readonly GUIContent disableWarningsLabel = new GUIContent("Disable warnings", "Disable warning messages in the Console.");

public static readonly GUIContent defaultSpriteAssetLabel = new GUIContent("Default Sprite Asset", "The Sprite Asset that will be assigned by default when using the <sprite> tag when no Sprite Asset is specified.");
public static readonly GUIContent missingSpriteCharacterUnicodeLabel = new GUIContent("Missing Sprite Unicode", "The unicode value for the sprite character to be displayed when the requested sprite character is not found in any sprite assets or fallbacks.");
public static readonly GUIContent enableEmojiSupportLabel = new GUIContent("iOS Emoji Support", "Enables Emoji support for Touch Screen Keyboards on target devices.");
//public static readonly GUIContent spriteRelativeScale = new GUIContent("Relative Scaling", "Determines if the sprites will be scaled relative to the primary font asset assigned to the text object or relative to the current font asset.");

Expand All @@ -74,6 +75,7 @@ internal class Styles
SerializedProperty m_PropEnableRaycastTarget;

SerializedProperty m_PropSpriteAsset;
SerializedProperty m_PropMissingSpriteCharacterUnicode;
//SerializedProperty m_PropSpriteRelativeScaling;
SerializedProperty m_PropEnableEmojiSupport;
SerializedProperty m_PropSpriteAssetPath;
Expand Down Expand Up @@ -102,6 +104,8 @@ internal class Styles
SerializedProperty m_PropFollowingCharacters;
SerializedProperty m_PropUseModernHangulLineBreakingRules;

private const string k_UndoRedo = "UndoRedoPerformed";

public void OnEnable()
{
if (target == null)
Expand All @@ -118,6 +122,7 @@ public void OnEnable()
m_PropEnableRaycastTarget = serializedObject.FindProperty("m_EnableRaycastTarget");

m_PropSpriteAsset = serializedObject.FindProperty("m_defaultSpriteAsset");
m_PropMissingSpriteCharacterUnicode = serializedObject.FindProperty("m_MissingCharacterSpriteUnicode");
//m_PropSpriteRelativeScaling = serializedObject.FindProperty("m_SpriteRelativeScaling");
m_PropEnableEmojiSupport = serializedObject.FindProperty("m_enableEmojiSupport");
m_PropSpriteAssetPath = serializedObject.FindProperty("m_defaultSpriteAssetPath");
Expand Down Expand Up @@ -164,6 +169,7 @@ public void OnEnable()
public override void OnInspectorGUI()
{
serializedObject.Update();
string evt_cmd = Event.current.commandName;

float labelWidth = EditorGUIUtility.labelWidth;
float fieldWidth = EditorGUIUtility.fieldWidth;
Expand Down Expand Up @@ -259,6 +265,7 @@ public override void OnInspectorGUI()
GUILayout.Label(Styles.defaultSpriteAssetLabel, EditorStyles.boldLabel);
EditorGUI.indentLevel = 1;
EditorGUILayout.PropertyField(m_PropSpriteAsset, Styles.defaultSpriteAssetLabel);
EditorGUILayout.PropertyField(m_PropMissingSpriteCharacterUnicode, Styles.missingSpriteCharacterUnicodeLabel);
EditorGUILayout.PropertyField(m_PropEnableEmojiSupport, Styles.enableEmojiSupportLabel);
//EditorGUILayout.PropertyField(m_PropSpriteRelativeScaling, Styles.spriteRelativeScale);
EditorGUILayout.PropertyField(m_PropSpriteAssetPath, Styles.spriteAssetsPathLabel);
Expand Down Expand Up @@ -313,7 +320,7 @@ public override void OnInspectorGUI()
EditorGUILayout.Space();
EditorGUILayout.EndVertical();

if (serializedObject.ApplyModifiedProperties())
if (serializedObject.ApplyModifiedProperties() || evt_cmd == k_UndoRedo)
{
EditorUtility.SetDirty(target);
TMPro_EventManager.ON_TMP_SETTINGS_CHANGED();
Expand Down
Loading

0 comments on commit 4700481

Please sign in to comment.