How do you get the number of characters in a text mesh pro object? I have a script that creates a bunch of textMeshPro objects, adds them to a list, and aligns them depending on their number in the list. But I would also like to space them apart depending on how many characters are in the string, here’s my script currently,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using System.Linq;
public class TextWheelFlooper : MonoBehaviour
{
public List<string> texts = new List<string>(1);
public List<TextMeshProUGUI> textPros;
private int numberCount = 0;
public Transform textWheelPosition;
public GameObject textObj;
void Start()
{
textWheelPosition = this.transform;
for (int i = 0; i < texts.Count; i++)
{
textPros.Add(Instantiate(textObj.GetComponent<TextMeshProUGUI>(),transform.position, Quaternion.identity, transform));
}
for (int i = 0; i < textPros.Count; i++)
{
textPros[i].transform.position = new Vector3(transform.position.x + i * textPros[i] * 10, transform.position.y, transform.position.z);
}
textPros[numberCount].transform.position = new Vector3(transform.position.x, transform.position.y + 10, transform.position.z);
for (int i = 0; i < texts.Count; i++)
{
textPros[i].text = texts[i];
}
}
public void NumberFlipUp()
{
}
}
obviously the + textPros is where I will be putting the character count… But how do I retrieve that? I’m trying to make a basic wheel that you can cycle through and whichever one is selected will be in the center, but in it’s current state, if the string is too long, they will overlap.
Thanks in advance.