Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.3.0] - 2018-08-09
### Changes
- Revamped UI to conform to Unity Human Interface Guidelines.
- Updated the title text on the Font Asset Creator window tab to "Font Asset Creator".
- Using TMP_Text.SetCharArray() with an empty char[] array will now clear the text.
- Made a small improvement to the TMP Input Field when using nested 2d RectMasks.
- Renamed symbol defines used by TMP to append TMP_ in front of the define to avoid potential conflicts with user defines.
- Improved the Project Files GUID Remapping tool to allow specifying a target folder to scan.
- Added the ability to cancel the scanning process used by the Project Files GUID Remapping tool.
- Moved TMP Settings to universal settings window in 2018.3 and above.
- Changing style sheet in the TMP Settings will now be reflected automatically on existing text objects in the editor.
- Added new function TMP_StyleSheet.UpdateStyleSheet() to update the internal reference to which style sheet text objects should be using in conjunction with the style tag.
  • Loading branch information
Unity Technologies committed Aug 8, 2018
1 parent b453736 commit 34d2485
Show file tree
Hide file tree
Showing 18 changed files with 342 additions and 173 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# Changelog
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

## [1.3.0] - 2018-05-30
## [1.3.0] - 2018-08-09
### Changes
- Revamped UI to conform to Unity Human Interface Guidelines.
- Updated the title text on the Font Asset Creator window tab to "Font Asset Creator".
- Using TMP_Text.SetCharArray() with an empty char[] array will now clear the text.
- Made a small improvement to the TMP Input Field when using nested 2d RectMasks.
- Renamed symbol defines used by TMP to append TMP_ in front of the define to avoid potential conflicts with user defines.
- Improved the Project Files GUID Remapping tool to allow specifying a target folder to scan.
- Added the ability to cancel the scanning process used by the Project Files GUID Remapping tool.
- Moved TMP Settings to universal settings window in 2018.3 and above.
- Changing style sheet in the TMP Settings will now be reflected automatically on existing text objects in the editor.
- Added new function TMP_StyleSheet.UpdateStyleSheet() to update the internal reference to which style sheet text objects should be using in conjunction with the style tag.

## [1.2.4] - 2018-06-10
### Changes
- Fixed a minor issue when using Justified and Flush alignment in conjunction with \u00A0.
- The Font Asset creationSettings field is no longer an Editor only serialized field.

## [1.2.3] - 2018-05-29
### Changes
Expand Down
83 changes: 74 additions & 9 deletions Scripts/Editor/TMP_PackageUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ struct AssetModificationRecord
public string assetDataFile;
}

private static string m_ProjectFolderToScan;
private static bool m_IsAlreadyScanningProject;
private static bool m_CancelScanProcess;
private static string k_ProjectScanReportDefaultText = "<color=#FFFF80><b>Project Scan Results</b></color>\n";
private static string m_ProjectScanResults = string.Empty;
private static Vector2 m_ProjectScanResultScrollPosition;
private static float m_ProgressPercentage = 0;
private static int m_ScanningTotalFiles;
private static int m_ScanningCurrentFileIndex;
private static string m_ScanningCurrentFileName;
private static List<AssetModificationRecord> m_ModifiedAssetList = new List<AssetModificationRecord>();


Expand All @@ -79,12 +82,17 @@ void OnGUI()
GUILayout.BeginVertical(EditorStyles.helpBox);
{
GUILayout.Label("Scan Project Files", EditorStyles.boldLabel);
GUILayout.Label("Press the <i>Scan Project Files</i> button to begin scanning your project for files & resources that were created with a previous version of TextMesh Pro", TMP_UIStyleManager.label);
GUILayout.Label("Press the <i>Scan Project Files</i> button to begin scanning your project for files & resources that were created with a previous version of TextMesh Pro.", TMP_UIStyleManager.label);
GUILayout.Space(10f);
GUILayout.Label("Project folder to be scanned. Example \"Assets/TextMesh Pro\"");
m_ProjectFolderToScan = EditorGUILayout.TextField("Folder Path: Assets/", m_ProjectFolderToScan);
GUILayout.Space(5f);

GUI.enabled = m_IsAlreadyScanningProject == false ? true : false;
if (GUILayout.Button("Scan Project Files"))
{
m_CancelScanProcess = false;

// Make sure Asset Serialization mode is set to ForceText and Version Control mode to Visible Meta Files.
if (CheckProjectSerializationAndSourceControlModes() == true)
{
Expand All @@ -100,6 +108,20 @@ void OnGUI()
// Display progress bar
Rect rect = GUILayoutUtility.GetRect(0f, 20f, GUILayout.ExpandWidth(true));
EditorGUI.ProgressBar(rect, m_ProgressPercentage, "Scan Progress (" + m_ScanningCurrentFileIndex + "/" + m_ScanningTotalFiles + ")");

// Display cancel button and name of file currently being scanned.
if (m_IsAlreadyScanningProject)
{
Rect cancelRect = new Rect(rect.width - 20, rect.y + 2, 20, 16);
if (GUI.Button(cancelRect, "X"))
{
m_CancelScanProcess = true;
}
GUILayout.Label("Scanning: " + m_ScanningCurrentFileName);
}
else
GUILayout.Label(string.Empty);

GUILayout.Space(5);

// Creation Feedback
Expand Down Expand Up @@ -170,25 +192,46 @@ private IEnumerator ScanProjectFiles()
AssetConversionData conversionData_Assets = JsonUtility.FromJson<AssetConversionData>(File.ReadAllText(packageFullPath + "/PackageConversionData_Assets.json"));

// Get list of GUIDs for assets that might contain references to previous GUIDs that require updating.
string[] projectGUIDs = AssetDatabase.FindAssets("t:Object");
string searchFolder = string.IsNullOrEmpty(m_ProjectFolderToScan) ? "Assets" : ("Assets/" + m_ProjectFolderToScan);
string[] projectGUIDs = AssetDatabase.FindAssets("t:Object", new string[] { searchFolder });
m_ScanningTotalFiles = projectGUIDs.Length;

bool cancelScanning = false;

// Iterate through projectGUIDs to search project assets of the types likely to reference GUIDs and FileIDs used by previous versions of TextMesh Pro.
for (int i = 0; i < projectGUIDs.Length; i++)
for (int i = 0; i < projectGUIDs.Length && cancelScanning == false; i++)
{
if (m_CancelScanProcess)
{
cancelScanning = true;
ResetScanProcess();

continue;
}

m_ScanningCurrentFileIndex = i + 1;

string guid = projectGUIDs[i];
string assetFilePath = AssetDatabase.GUIDToAssetPath(guid);
string assetFileExtension = Path.GetExtension(assetFilePath);
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetFilePath);

// Filter out asset types that we can't read or have not interest in searching.
if (assetType == typeof(DefaultAsset) || assetType == typeof(MonoScript) || assetType == typeof(Texture2D) ||
if (assetType == typeof(DefaultAsset) || assetType == typeof(MonoScript) || assetType == typeof(Texture2D) || assetType == typeof(Texture3D) || assetType == typeof(Cubemap) ||
assetType == typeof(TextAsset) || assetType == typeof(Shader) || assetType == typeof(Font) || assetType == typeof(UnityEditorInternal.AssemblyDefinitionAsset) ||
assetType == typeof(GUISkin) || assetType == typeof(PhysicsMaterial2D) || assetType == typeof(UnityEngine.U2D.SpriteAtlas) || assetType == typeof(UnityEngine.Tilemaps.Tile) ||
assetType == typeof(AudioClip) || assetType == typeof(ComputeShader) || assetType == typeof(UnityEditor.Animations.AnimatorController))
assetType == typeof(GUISkin) || assetType == typeof(PhysicsMaterial2D) || assetType == typeof(PhysicMaterial) || assetType == typeof(UnityEngine.U2D.SpriteAtlas) || assetType == typeof(UnityEngine.Tilemaps.Tile) ||
assetType == typeof(AudioClip) || assetType == typeof(ComputeShader) || assetType == typeof(UnityEditor.Animations.AnimatorController) || assetType == typeof(UnityEngine.AI.NavMeshData) ||
assetType == typeof(Mesh) || assetType == typeof(RenderTexture) || assetType == typeof(Texture2DArray) || assetType == typeof(LightingDataAsset) || assetType == typeof(AvatarMask) ||
assetType == typeof(AnimatorOverrideController) || assetType == typeof(TerrainData) || assetType == typeof(HumanTemplate) || assetType == typeof(Flare) || assetType == typeof(UnityEngine.Video.VideoClip))
continue;

// Exclude FBX
if (assetType == typeof(GameObject) && (assetFileExtension == ".FBX" || assetFileExtension == ".fbx"))
continue;

m_ScanningCurrentFileName = assetFilePath;
//Debug.Log("Searching Asset: [" + assetFilePath + "] with file extension [" + assetFileExtension + "] of type [" + assetType + "]");

// Read the asset data file
string assetDataFile = string.Empty;
try
Expand All @@ -201,8 +244,6 @@ private IEnumerator ScanProjectFiles()
continue;
}

//Debug.Log("Searching Asset: [" + assetFilePath + "] of type: " + assetType);

bool hasFileChanged = false;

// Special handling / optimization if assetType is null
Expand Down Expand Up @@ -255,8 +296,16 @@ private IEnumerator ScanProjectFiles()
}

// Iterate through projectGUIDs (again) to search project meta files which reference GUIDs used by previous versions of TextMesh Pro.
for (int i = 0; i < projectGUIDs.Length; i++)
for (int i = 0; i < projectGUIDs.Length && cancelScanning == false; i++)
{
if (m_CancelScanProcess)
{
cancelScanning = true;
ResetScanProcess();

continue;
}

string guid = projectGUIDs[i];
string assetFilePath = AssetDatabase.GUIDToAssetPath(guid);
string assetMetaFilePath = AssetDatabase.GetTextMetaFilePathFromAssetPath(assetFilePath);
Expand All @@ -266,6 +315,8 @@ private IEnumerator ScanProjectFiles()

bool hasFileChanged = false;

m_ScanningCurrentFileName = assetMetaFilePath;

foreach (AssetConversionRecord record in conversionData.assetRecords)
{
if (assetMetaFile.Contains(record.target))
Expand Down Expand Up @@ -298,6 +349,20 @@ private IEnumerator ScanProjectFiles()
}

m_IsAlreadyScanningProject = false;
m_ScanningCurrentFileName = string.Empty;
}


/// <summary>
///
/// </summary>
private static void ResetScanProcess()
{
m_IsAlreadyScanningProject = false;
m_ScanningCurrentFileName = string.Empty;
m_ProgressPercentage = 0;
m_ScanningCurrentFileIndex = 0;
m_ScanningTotalFiles = 0;
}


Expand Down
6 changes: 2 additions & 4 deletions Scripts/Editor/TMP_ProjectTextSettings.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if !UNITY_2018_3_OR_NEWER
using UnityEditor;


namespace TMPro
{

Expand Down Expand Up @@ -43,3 +40,4 @@ static void ON_RESOURCES_LOADED()
}
}
}
#endif
33 changes: 26 additions & 7 deletions Scripts/Editor/TMP_SettingsEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ namespace TMPro.EditorUtilities
[CustomEditor(typeof(TMP_Settings))]
public class TMP_SettingsEditor : Editor
{
static class Styles
class Styles
{
static Styles() { }

public static readonly GUIContent defaultFontAssetLabel = new GUIContent("Default Font Asset", "The Font Asset that will be assigned by default to newly created text objects when no Font Asset is specified.");
public static readonly GUIContent defaultFontAssetPathLabel = new GUIContent("Path: Resources/", "The relative path to a Resources folder where the Font Assets and Material Presets are located.\nExample \"Fonts & Materials/\"");

Expand Down Expand Up @@ -88,6 +86,9 @@ static Styles() { }

public void OnEnable()
{
if (target == null)
return;

m_PropFontAsset = serializedObject.FindProperty("m_defaultFontAsset");
m_PropDefaultFontAssetPath = serializedObject.FindProperty("m_defaultFontAssetPath");
m_PropDefaultFontSize = serializedObject.FindProperty("m_defaultFontSize");
Expand All @@ -109,7 +110,7 @@ public void OnEnable()
{
var element = m_List.serializedProperty.GetArrayElementAtIndex(index);
rect.y += 2;
EditorGUI.PropertyField( new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element, GUIContent.none);
EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element, GUIContent.none);
};

m_List.drawHeaderCallback = rect =>
Expand All @@ -136,6 +137,9 @@ public override void OnInspectorGUI()
{
serializedObject.Update();

float labelWidth = EditorGUIUtility.labelWidth;
float fieldWidth = EditorGUIUtility.fieldWidth;

// TextMeshPro Font Info Panel
EditorGUI.indentLevel = 0;

Expand Down Expand Up @@ -203,8 +207,8 @@ public override void OnInspectorGUI()
}
EditorGUILayout.EndHorizontal();

EditorGUIUtility.labelWidth = 0;
EditorGUIUtility.fieldWidth = 0;
EditorGUIUtility.labelWidth = labelWidth;
EditorGUIUtility.fieldWidth = fieldWidth;

EditorGUILayout.PropertyField(m_PropWordWrapping, Styles.wordWrappingLabel);
EditorGUILayout.PropertyField(m_PropKerning, Styles.kerningLabel);
Expand All @@ -214,7 +218,6 @@ public override void OnInspectorGUI()

EditorGUILayout.PropertyField(m_PropParseEscapeCharacters, Styles.parseEscapeCharactersLabel);

EditorGUIUtility.labelWidth = 0;
EditorGUI.indentLevel = 0;

EditorGUILayout.Space();
Expand All @@ -236,7 +239,13 @@ public override void OnInspectorGUI()
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
GUILayout.Label(Styles.defaultStyleSheetLabel, EditorStyles.boldLabel);
EditorGUI.indentLevel = 1;
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_PropStyleSheet, Styles.defaultStyleSheetLabel);
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();
TMP_StyleSheet.UpdateStyleSheet();
}
EditorGUI.indentLevel = 0;

EditorGUILayout.Space();
Expand Down Expand Up @@ -270,5 +279,15 @@ public override void OnInspectorGUI()
}

}

#if UNITY_2018_3_OR_NEWER
[SettingsProvider]
static SettingsProvider CreateTMPSettingsProvider()
{
var provider = new AssetSettingsProvider("Project/TextMesh Pro", () => TMP_Settings.instance);
provider.PopulateSearchKeywordsFromGUIContentProperties<Styles>();
return provider;
}
#endif
}
}
39 changes: 23 additions & 16 deletions Scripts/Editor/TMPro_ContextMenus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,35 +166,42 @@ static void ResetSettings(MenuCommand command)
mat = Selection.activeGameObject.GetComponent<CanvasRenderer>().GetMaterial();
}


//Material mat = (Material)command.context;
Undo.RecordObject(mat, "Reset Material");

Material tmp_mat = new Material(mat.shader);

ShaderUtilities.GetShaderPropertyIDs(); // Make sure we have valid Property IDs
if (mat.HasProperty(ShaderUtilities.ID_GradientScale))
{
// Copy unique properties of the SDF Material over to the temp material.
tmp_mat.SetTexture(ShaderUtilities.ID_MainTex, mat.GetTexture(ShaderUtilities.ID_MainTex));
tmp_mat.SetFloat(ShaderUtilities.ID_GradientScale, mat.GetFloat(ShaderUtilities.ID_GradientScale));
tmp_mat.SetFloat(ShaderUtilities.ID_TextureWidth, mat.GetFloat(ShaderUtilities.ID_TextureWidth));
tmp_mat.SetFloat(ShaderUtilities.ID_TextureHeight, mat.GetFloat(ShaderUtilities.ID_TextureHeight));
tmp_mat.SetFloat(ShaderUtilities.ID_StencilID, mat.GetFloat(ShaderUtilities.ID_StencilID));
tmp_mat.SetFloat(ShaderUtilities.ID_StencilComp, mat.GetFloat(ShaderUtilities.ID_StencilComp));

mat.CopyPropertiesFromMaterial(tmp_mat);
// Copy unique properties of the SDF Material
var texture = mat.GetTexture(ShaderUtilities.ID_MainTex);
var gradientScale = mat.GetFloat(ShaderUtilities.ID_GradientScale);
var texWidth = mat.GetFloat(ShaderUtilities.ID_TextureWidth);
var texHeight = mat.GetFloat(ShaderUtilities.ID_TextureHeight);
var stencilId = mat.GetFloat(ShaderUtilities.ID_StencilID);
var stencilComp = mat.GetFloat(ShaderUtilities.ID_StencilComp);
var normalWeight = mat.GetFloat(ShaderUtilities.ID_WeightNormal);
var boldWeight = mat.GetFloat(ShaderUtilities.ID_WeightBold);

// Reset the material
Unsupported.SmartReset(mat);

// Reset ShaderKeywords
mat.shaderKeywords = new string[0]; // { "BEVEL_OFF", "GLOW_OFF", "UNDERLAY_OFF" };

// Copy unique material properties back to the material.
mat.SetTexture(ShaderUtilities.ID_MainTex, texture);
mat.SetFloat(ShaderUtilities.ID_GradientScale, gradientScale);
mat.SetFloat(ShaderUtilities.ID_TextureWidth, texWidth);
mat.SetFloat(ShaderUtilities.ID_TextureHeight, texHeight);
mat.SetFloat(ShaderUtilities.ID_StencilID, stencilId);
mat.SetFloat(ShaderUtilities.ID_StencilComp, stencilComp);
mat.SetFloat(ShaderUtilities.ID_WeightNormal, normalWeight);
mat.SetFloat(ShaderUtilities.ID_WeightBold, boldWeight);
}
else
{
mat.CopyPropertiesFromMaterial(tmp_mat);
Unsupported.SmartReset(mat);
}

DestroyImmediate(tmp_mat);

TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, mat);
}

Expand Down
4 changes: 2 additions & 2 deletions Scripts/Editor/TMPro_FontAssetCreatorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class TMPro_FontAssetCreatorWindow : EditorWindow
public static void ShowFontAtlasCreatorWindow()
{
var window = GetWindow<TMPro_FontAssetCreatorWindow>();
window.titleContent = new GUIContent("Font Creator");
window.titleContent = new GUIContent("Font Asset Creator");
window.Focus();

// Make sure TMP Essential Resources have been imported.
Expand All @@ -27,7 +27,7 @@ public static void ShowFontAtlasCreatorWindow(Font sourceFontFile)
{
var window = GetWindow<TMPro_FontAssetCreatorWindow>();

window.titleContent = new GUIContent("Font Creator");
window.titleContent = new GUIContent("Font Asset Creator");
window.Focus();

// Override selected font asset
Expand Down
4 changes: 4 additions & 0 deletions Scripts/Runtime/PackageResourceImporterWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ void ImportCallback(string packageName)
{
k_EssentialResourcesImported = true;
TMPro_EventManager.ON_RESOURCES_LOADED();

#if UNITY_2018_3_OR_NEWER
SettingsService.NotifySettingsProviderChanged();
#endif
}
else if (packageName == "TMP Examples & Extras")
{
Expand Down
Loading

0 comments on commit 34d2485

Please sign in to comment.