How to create 360 curved text?

Hello all

I need to have a sentence surrounding the player, how should I approach this?

Let me tell you what I’ve tried already:
Text mesh pro - no results

Curvy - no results (good for 2d circle only)

several curved ui scripts - no results (good for 2d only)

Curved UI - no results (good for 180 degrees only)

for each of these something didn’t work well

After reading the relevant scripts its seems to be related to UIVertex, but it’s too much for me to tweek this type of code. I need more c# knowledge

EDIT: Like in this picture (the use is in the middle of the circle)124287-text-surrounding-the-user.png

Ok first of all you have to create a Prefab.

  1. Create an EmptyGameObject. / Zero the Position and Rotation
  2. Add as Child TextMeshPro - Text. / Rotate the Rect Transform around 180 degrees.
  3. In the Font Settings set the Alignment to Center and Middle
  4. Add the Prefab to the Propertyfield Text Mesh Prefab.

this is just a basic Code which you might want to extend. The bools are just for debugging purpose.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

[ExecuteInEditMode]
public class TextArroundPlayer : MonoBehaviour
{
    public string RoundText = "";
    public float Radius = 10;
    public GameObject TextMeshPrefab;
    public bool join,destroy;
    List<GameObject> prefabs = new List<GameObject>();
    void Update()
    {
        if(join)
        {
            Vector3 center = transform.position;
            float ang = 0;
            for (int i = 0; i < RoundText.Length; i++)
            {
                Vector3 pos = RandomCircle(center, Radius,ang);
                Quaternion rot = Quaternion.FromToRotation(Vector3.forward, center-pos);
                prefabs.Add(Instantiate(TextMeshPrefab, pos, rot));
                char c = RoundText;
                    prefabs.GetComponentInChildren<TextMeshPro>().text = c.ToString();
                ang += 360 / RoundText.Length-1;
            }
            prefabs[0].transform.rotation = Quaternion.Euler(0,prefabs[0].transform.rotation.y,prefabs[0].transform.rotation.z);
            join = false;
        }
        if(destroy)
        {
            for(int i = 0;i<prefabs.Count;i++)
            {
                DestroyImmediate(prefabs);
            }
            prefabs = new List<GameObject>();
            destroy = false;
        }
    }

    Vector3 RandomCircle ( Vector3 center ,float radius,float ang)
    {
        Vector3 pos;
        pos.x = center.x + radius * Mathf.Sin(ang * Mathf.Deg2Rad);
        pos.y = center.y;
        pos.z = center.z + radius * Mathf.Cos(ang * Mathf.Deg2Rad);
        return pos;
    }
 
}

EDIT:

Added 2 Screenshot of the TextMesh variation…

[124344-textmesh1.png|124344]
[124345-textmesh2.png|124345]

If you can code, this is one method that I have used.

The way is, inheriting Text and override OnPopulateMesh method.
This code works for my settings but not sure if it will suit yours.

public class CurvedText : Text
{
    public float diameter = 200;
      
    protected override void OnPopulateMesh(VertexHelper vh)
    {
        base.OnPopulateMesh(vh);
      
        for (int i = 0; i < vh.currentVertCount; i++)
        {
            UIVertex vert = UIVertex.simpleVert;
            vh.PopulateUIVertex(ref vert, i);
            Vector3 position = vert.position;
      
            //manipulate position
            float ratio = (float)position.x / preferredWidth;
            float mappedRatio = ratio * 2 * Mathf.PI;
            float cos = Mathf.Cos(mappedRatio);
            float sin = Mathf.Sin(mappedRatio);
      
            position.x = -cos * diameter;
            position.z = sin * diameter;
      
            vert.position = position;
            vh.SetUIVertex(vert, i);
        }
    }
}

I wish it helps.

thanks @dan_wipf I did well up until 4, and then I lost you…

I have two text mesh pro prefabs called: TextMeshPro-Prefab 1, TextMeshPro-Prefab 2

None of them as seems doen’s have property field.

What am I missing? WELL OF COURSE the script you’ve attached!

Trying this now!
update:
I created the empty gameobject with a child text - TMP
I created another gameobject and called it TextAroundPlayer, but when attaching the script got this pop-up: 124296-what-i-got-when-adding-the-script.png

When tried to attach the script to other objects, same error

The solutions here didn’t work for me, so I used Blender instead. While curving text is possible directly in the game engine, it’s much easier to accomplish using Blender, even for someone who’s never used it before.

To create 3D curved text in Blender 4.0:

  1. Add a bezier circle mesh (Shift A>Curves>Circle)
  2. Add a text mesh (Shift A>Text)
  3. Select the text mesh and go to the modifiers tab on the right hand panel
  4. On the modifiers tab add a curve modifier (Add Modifier>Search>Curve)
  5. Click the box next to the “Curve Object” property, and select your circular curve object from the dropdown (probably called Bezier Circle or something similar)
  6. Rotate the text 90 degrees over the x-axis (R>X>Type 90>Enter)

For a more detailed tutorial, check out this video

Hope this helps some people!