I'm having a really hard time figuring out how to get this relatively simple script to work with text mesh pro. This is a photo of what I'm attempting and is working with my old script:
This could just be a settings issue and not a coding issue. Here is the script:
using System.Collections;
using UnityEngine.UI;
using System;
using System.Collections.Generic;
using TMPro;
[ExecuteInEditMode]
public class CurvedText : Text
{
public float radius = 0.5f;
public float wrapAngle = 360.0f;
public float scaleFactor = 100.0f;
private float circumference
{
get
{
if (_radius != radius || _scaleFactor != scaleFactor)
{
_circumference = 2.0f * Mathf.PI * radius * scaleFactor;
_radius = radius;
_scaleFactor = scaleFactor;
}
return _circumference;
}
}
private float _radius = -1;
private float _scaleFactor = -1;
private float _circumference = -1;
protected override void OnValidate()
{
base.OnValidate();
if (radius <= 0.0f)
{
radius = 0.001f;
}
if (scaleFactor <= 0.0f)
{
scaleFactor = 0.001f;
}
}
protected override void OnPopulateMesh(VertexHelper vh)
{
base.OnPopulateMesh(vh);
List<UIVertex> stream = new List<UIVertex>();
vh.GetUIVertexStream(stream);
for (int i = 0; i < stream.Count; i++)
{
UIVertex v = stream[i];
float percentCircumference = v.position.x / circumference;
Vector3 offset = Quaternion.Euler(0.0f, 0.0f, -percentCircumference * 360.0f) * Vector3.up;
v.position = offset * radius * scaleFactor + offset * v.position.y;
v.position += Vector3.down * radius * scaleFactor;
stream[i] = v;
}
vh.AddUIVertexTriangleStream(stream);
}
void Update()
{
if (radius <= 0.0f)
{
radius = 0.001f;
}
if (scaleFactor <= 0.0f)
{
scaleFactor = 0.001f;
}
rectTransform.sizeDelta = new Vector2(circumference * wrapAngle / 360.0f, rectTransform.sizeDelta.y);
}
}
Which gives me a circle a of text and is working exactly as intended. I'd really just like to update to text mesh pro to do some fun stuff with materials and shader graph < when I tried with the legacy text it all just appeared to be blocks or the individual letters didn't have a mesh which led me to seeking this upgrade.
public class CurvedText : TextMeshPro
When I changed to the above it seemed simple enough, but then no text would show. I realized this was because so font was selected. Then I realized the font size defaulted to -99 for some reason. I experimented changing different settings for over an hour to no avail. I included screenshots of all the possible settings.
If someone could either help me adjust these settings to get the text to show up, or help me reconfigure the script for text mesh pro id really appreciate it. Thanks


