Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Eco-Editor · Sep 10, 2018 at 09:58 AM · textvertex3dtext360-degreescurved path

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)alt text

text-surrounding-the-user.png (15.1 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image misher · Sep 10, 2018 at 03:32 PM 0
Share

If after so much different approaches you still have no results, there must be some specific requirements you did nor mention in your question. "Surrounding the player" can mean many things. Can you provide more details...

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by maxoja · Sep 10, 2018 at 07:02 PM

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eco-Editor · Sep 10, 2018 at 09:45 PM 0
Share

@maxoja Thank you

It works for me! now I need to apply an animation and it's good to go! Great script

avatar image maxoja Eco-Editor · Sep 11, 2018 at 09:26 PM 0
Share

Happy to be able to help you ^^

avatar image
3

Answer by dan_wipf · Sep 10, 2018 at 05:44 PM

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[i];
                     prefabs[i].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[i]);
                 }
                 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..

alt text

alt text


textmesh2.png (502.4 kB)
textmesh1.png (499.5 kB)
Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eco-Editor · Sep 10, 2018 at 06:37 PM 0
Share

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

I have two text mesh pro prefabs called: Text$$anonymous$$eshPro-Prefab 1, Text$$anonymous$$eshPro-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 - T$$anonymous$$P I created another gameobject and called it TextAroundPlayer, but when attaching the script got this pop-up: alt text

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

what-i-got-when-adding-the-script.png (21.0 kB)
avatar image dan_wipf · Sep 10, 2018 at 07:43 PM 0
Share

ok in inspector right click and select empty gameobject. find it in the scene. Rename it as you’d like to and set the transforms position and rotation to 0


right click in inspector on the created game objecte, and select in the submenu of 3d GameObjects text mesh no it should be a child of the above created gameobject. in the rect transform of the new text mesh make x&y position as well zero


in the text mesh component choose the alignment of the text center and middle


now drag and drop the gameobject to your asset folder. now you have the prefab. you can now delet the created object in the inspector.


now attach the script to your Player. in the inspector there should be now a field which is called Text $$anonymous$$esh Prefab. Drag and drop the created prefab from your asset folder to it. now you can type something in to the string field and hit join


avatar image Eco-Editor dan_wipf · Sep 10, 2018 at 09:46 PM 0
Share

Ok, I had a misspelled the scripts' name. that's why the pop up window appeared. It didn't work for me though Is it working in your scene?

Thanks

avatar image dan_wipf Eco-Editor · Sep 11, 2018 at 12:29 AM 1
Share

I edited my Answer.. it works for me perfectly =)

Show more comments
Show more comments
avatar image KateSu · Dec 23, 2020 at 12:54 AM 1
Share

works, thank you!

avatar image dan_wipf KateSu · Dec 23, 2020 at 06:36 AM 0
Share

you're wellcome

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

97 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Cannot get 3D Text/Text Mesh to wrap or a attached collider used as a button to scale based on word count. 2 Answers

int to string problem 4 Answers

Insert 3d text to the front face of a cube GameObject 0 Answers

3d text color 2 Answers

Unity3d Battery Life Change 3D text Java script 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges