• Stars
    star
    113
  • Rank 309,052 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created about 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Upgrade Text, InputField, Dropdown and TextMesh objects to their TextMesh Pro variants in Unity

Text To TextMesh Pro Upgrade Tool for Unity

screenshot

Available on Asset Store: https://assetstore.unity.com/packages/tools/utilities/text-to-textmesh-pro-upgrade-tool-176732

Forum Thread: https://forum.unity.com/threads/text-to-textmesh-pro-upgrade-tool-open-source.947948/

Discord: https://discord.gg/UJJt549AaV

GitHub Sponsors ☕

This asset helps you upgrade the Text, InputField, Dropdown and TextMesh objects in your projects to their TextMesh Pro variants. It also upgrades the scripts so that e.g. Text variables in those scripts become TMP_Text variables. Then, it reconnects the references to the upgraded components (e.g. if a public variable was referencing an upgraded Text component, it will now reference the corresponding TextMeshProUGUI component).

INSTALLATION

There are 5 ways to install this plugin:

  • import TextToTMP.unitypackage via Assets-Import Package
  • clone/download this repository and move the Plugins folder to your Unity project's Assets folder
  • import it from Asset Store
  • (via Package Manager) add the following line to Packages/manifest.json:
    • "com.yasirkula.texttotmp": "https://github.com/yasirkula/UnityTextToTextMeshProUpgradeTool.git",
  • (via OpenUPM) after installing openupm-cli, run the following command:
    • openupm add com.yasirkula.texttotmp

HOW TO

Before proceeding, you are strongly recommended to backup your project; just in case.

  • Open the Window-Upgrade Text to TMP window
  • Add the prefabs, Scenes, scripts and ScriptableObjects to upgrade to the Assets & Scenes To Upgrade list (if you add a folder there, its whole contents will be upgraded)(ScriptableObjects' Font variables will be upgraded). If an Object wasn't added to that list but it had references to the upgraded components, those references will be lost
  • To determine which Unity Fonts will be upgraded to which TextMesh Pro FontAssets, use the Font Upgrades list
  • Hit START and then follow the presented instructions. To summarize:
    • Step 1/3: Upgrading Scripts: Decide which scripts should be upgraded; e.g. Text variables in those scripts will become TMP_Text variables
    • Step 2/3: Upgrading Components: Decide which prefabs/Scenes should be upgraded; e.g. Text components in those prefabs/Scenes will be upgraded to TextMeshProUGUI components
    • Step 3/3: Reconnecting References: Decide whether or not the references to the upgraded components should be restored; e.g. if a public variable was referencing an upgraded Text component, it will now reference the corresponding TextMeshProUGUI component

KNOWN LIMITATIONS

  • InputField.onSubmit event isn't serialized on TMP_InputField so in order not to lose references to its listeners, TMP_InputFieldOnSubmitEvent component will be attached to the upgraded InputField objects with non-empty onSubmit events automatically. It means that if you delete this plugin after the upgrade process, all instances of that component (if any) will be broken. However, you can duplicate the TMP_InputFieldOnSubmitEvent script, delete the plugin, and then change the duplicated script's GUID to the original script's GUID to restore those references, if you wish
  • If an InputField or Dropdown prefab instance's UnityEvent is modified (i.e. it's different from the prefab asset), that modification can't be restored after the upgrade process on Unity 2019.2 or earlier if a script was modified during the upgrade process

EXAMPLES

Add Plugins/RuntimeInspector folder to the Assets & Scenes To Upgrade list and then upgrade everything (scripts, components, references). No manual intervention necessary.

Add Plugins/IngameDebugConsole folder to the Assets & Scenes To Upgrade list and then upgrade everything. No manual intervention necessary.

Upgrading DynamicPanels

Add Plugins/DynamicPanels folder to the Assets & Scenes To Upgrade list and then upgrade everything. While upgrading the scripts, DynamicPanelsCanvasEditor.cs will throw a compiler error. Fix it as follows before proceeding to upgrade the components:

anchoredPanelGUIStyle = new GUIStyle( "box" )
{
	alignment = TextAnchor.MiddleCenter, // <-- Changed here to TextAnchor.MiddleCenter
	clipping = TextClipping.Clip
};

What happened: While UI system uses TextAnchor, TMP uses TextAlignmentOptions. The plugin assumed that it was upgrading a Text's alignment property here but it was actually breaking a GUIStyle's alignment property. While upgrading the scripts, the plugin doesn't use advanced stuff like lexers in order to avoid any 3rd party dependencies. However, this can result in rare false positives like this.

Add Plugins/SimpleFileBrowser folder to the Assets & Scenes To Upgrade list and then upgrade everything. No manual intervention necessary.

Upgrading ImageCropper

Add Plugins/ImageCropper folder to the Assets & Scenes To Upgrade list and then upgrade everything. While upgrading the scripts, FontSizeSynchronizer.cs will throw a compiler error. Fix it as follows before proceeding to upgrade the components:

private void Awake()
{
	if( texts.Length == 0 )
		return;

	canvas = texts[0].canvas;

	initialBestFitSizes = new int[texts.Length];
	for( int i = 0; i < texts.Length; i++ )
		initialBestFitSizes[i] = (int) texts[i].fontSizeMax; // <-- Added (int) typecast here
}

// Credit: https://forum.unity.com/threads/textmeshpro-precull-dorebuilds-performance.762968/#post-5083490
public void Synchronize()
{
	if( canvas == null || !gameObject.activeInHierarchy )
		return;

	int minSize = int.MaxValue;
	for( int i = 0; i < texts.Length; i++ )
	{
		TMPro.TMP_Text text = texts[i];

		text.fontSizeMax = initialBestFitSizes[i];
		text.enableAutoSizing = true;
		text.ForceMeshUpdate();

		int fontSize = (int) text.fontSize;
		if( fontSize < minSize )
			minSize = fontSize;
	}

	for( int i = 0; i < texts.Length; i++ )
	{
		texts[i].fontSize = minSize;
		texts[i].enableAutoSizing = false;
	}
}

What happened: Previously, we were using TextGenerator to calculate the Best Fit font size but TextMesh Pro doesn't use TextGenerator, so we had to upgrade this function manually.

More Repositories

1

UnityIngameDebugConsole

A uGUI based console to see debug messages and execute commands during gameplay in Unity
C#
2,117
star
2

UnityAssetUsageDetector

Find usages of the selected asset(s) and/or Object(s) in your Unity project, i.e. list the objects that refer to them
C#
1,693
star
3

UnityRuntimeInspector

Runtime Inspector and Hierarchy solution for Unity for debugging and runtime editing purposes
C#
1,676
star
4

UnityNativeGallery

A native Unity plugin to interact with Gallery/Photos on Android & iOS (save and/or load images/videos)
Objective-C++
1,396
star
5

UnityBezierSolution

A bezier spline solution for Unity 3D with some utility functions (like travelling the spline with constant speed/time)
C#
1,153
star
6

UnityNativeShare

A Unity plugin to natively share files (images, videos, documents, etc.) and/or plain text on Android & iOS
C#
905
star
7

UnitySimpleFileBrowser

A uGUI based runtime file browser for Unity 3D (draggable and resizable)
C#
844
star
8

UnityDynamicPanels

Draggable, resizable, dockable and stackable UI panel solution for Unity 3D
C#
735
star
9

UnityNativeCamera

A native Unity plugin to take pictures/record videos with device camera on Android & iOS
C#
605
star
10

UnityRuntimePreviewGenerator

Generate preview textures (thumbnails) for your GameObject's or materials on the fly in Unity
C#
304
star
11

UnityNativeFilePicker

A native Unity plugin to import/export files from/to various document providers on Android & iOS
C#
277
star
12

UnityInspectPlus

Speeding up your Inspector workflow in Unity 3D
C#
254
star
13

UnityImageCropper

A uGUI based image cropping solution for Unity 3D
C#
207
star
14

UnityAndroidRuntimePermissions

A native Unity plugin to handle runtime permissions on Android M+
C#
194
star
15

UnityRuntimeSceneGizmo

Interactable runtime scene gizmo for uGUI
C#
175
star
16

UnitySimplePatchTool

Unity port of SimplePatchTool library to add patching support to standalone Unity applications
C#
163
star
17

UnitySimpleInput

An improvement over Unity's legacy Input system that allows you to use custom input providers like on-screen joysticks, UI buttons and d-pads
C#
157
star
18

UnityAdjustPivot

Adjust pivot point of an object in Unity without creating an empty parent object
C#
149
star
19

Unity360ScreenshotCapture

A simple script to capture 360° screenshots in-game with Unity
C#
142
star
20

SimplePatchTool

C# library for patching standalone applications with binary diff and self patching support
C#
132
star
21

DownloadLinkGeneratorForGoogleDrive

Create list of files and their download links in a Google Driveâ„¢ folder
HTML
109
star
22

UnityIonicIntegration

A guide to integrating Unity 3D content into an Ionic app and sending messages between them (for Android & iOS)(tested with Vuforia plugin)
Objective-C++
104
star
23

UnityMobileLocalizedAppTitle

Localize your Unity app's name and/or icon on Android & iOS
C#
102
star
24

UnityGridFramework

Open source Grid Framework for creating grid-based levels easily in Unity 3D
C#
94
star
25

UnitySimpleGDPRConsent

A Unity plugin to present GDPR consent dialogs to the users
C#
93
star
26

UnityTextureOps

A basic image processing plugin for Unity
C#
87
star
27

UnityChoiceOfGamesSaveManager

Save manager for 'Choice of Games' on Steam - Created with Unity 3D
C#
76
star
28

UnitySpeechToText

A native Unity plugin to convert speech to text on Android & iOS
C#
70
star
29

UnityRuntimeTexture

An abstraction layer on top of Texture2D.LoadImage to create Texture2D objects at runtime from raw PNG/JPEG data in Unity
C#
62
star
30

UnityDashedSpriteShape

Creating dashed (dotted) 2D Sprite Shapes in Unity
ShaderLab
62
star
31

UnityMobileRemoteControl

Control your Windows device from your phone
C#
59
star
32

UnityEditorGoogleDriveIntegration

Access your Google Driveâ„¢ files from within Unity editor
C#
48
star
33

UnityHexicGame

Hexic puzzle game made with Unity 3D
ShaderLab
36
star
34

UnityGenericPool

A simple generic pooling script for Unity3D with a helper class
C#
36
star
35

UnitySpinningLoadingBars

3 different spinning loading bar prefabs for Unity's UI system
28
star
36

UnityFlatColorPalettes

A number of flat color palettes for Unity 3D
26
star
37

UnityEveryplaySaveToLocal

A helper script to save captured Everyplay videos to local file system on Android & iOS
Objective-C++
15
star
38

UnityOrderedUpdate

Receive Update callback(s) from anywhere and in any order in Unity!
C#
15
star
39

UnityAndroidStreamingAssets

A helper script to extract StreamingAssets to local file system on Unity Android
C#
10
star
40

DownloadLinkGeneratorForDropbox

Create list of files and their download links in a Dropbox folder
HTML
6
star
41

SecondHand

Global Game Jam entry
C#
5
star
42

GeometricSketchpadProject

Bilkent CS102 Course Project
Java
4
star
43

GreenHellMods

A number of mods created via ModAPI for Green Hell game
C#
4
star
44

.github

Default GitHub community health files for all my repositories
2
star
45

BubblesProject

Bilkent CS319 Course Project
Java
2
star