TextMeshPro Converter
This is a tool to convert existing UI at the scene from default Text
and InputField
to the TextMeshPro equivalent components.
Converter available with the context menu UI/New UI Widgets/Replace Unity Text with TextMeshPro or with Window/New UI Widgets/Replace Unity Text with TextMeshPro.
Scripts references to Text
and InputField
components will be automatically replaced if type of reference is common base type like Graphic
or MonoBehaviour
; otherwise those components will not be converted.
Limitations:
If you have any scripts with the serialized fields of type
Text
orInputField
with specified components, then those components will not be converted.[SerializeField] Text Name; // cannot be converted [SerializeField] Graphic SecondName; // can be converted [SerializeField] TextAdapter ThirdName; // can be converted
Solutions:
manualy change type to the
TextAdapter
orInputFieldAdapter
and add the corresponding component to the referenced GameObjectmodify code to automatically replace components with adapters
Modify Code to Adapters
Original script:
class SomeComponent : MonoBehaviour
{
[SerializeField]
Text Name;
public void SomeMethod()
{
Name.text = "value";
}
}
Modification:
class SomeComponent : MonoBehaviour, IUpgradeable
{
[SerializeField]
[System.Obsolete("Replaced with NameAdapter.")]
Text Name;
[SerializeField]
TextAdapter NameAdapter;
public void SomeMethod()
{
NameAdapter.text = "value";
}
public virtual void Upgrade()
{
Utilities.GetOrAddComponent(Name, ref NameAdapter);
}
#if UNITY_EDITOR
protected virtual void OnValidate()
{
Upgrade();
}
#endif
}
Note
If you undo convertation you can see warnings like Not found any Text/InputField/InputFieldExtended component. This is happening because the newly added TMPro components was deleted and the old default components are not yet restored. In such cases, those warnings should be ignored.