Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity How do I Flow TextMesh Pro Text around an Image?

Unity Version: 5.6.5f1 Personal

TextMesh Pro Version: 1.0.56.0b3

I have a TextMesh Pro UI Text object whose area intersects the area of a UI Image. The text is dynamic, but the image will never change. Is there a way to make the TextMesh Pro UI Text flow around the image similar to how text would wrap to one side in HTML/CSS?

The image below shows two copies of the object in Unity. One object, denoted by a red space where the image is located, is what I'm currently getting. The text enters the space of the image. The other object, denoted by a blue space where the image is located, shows the desired outcome where text is wrapping properly.

Current vs. Desired Outcome: Current vs. Desired Outcome

Research so far:

How do I put an image inside text? - The Image that I'm using is a UI Image, not a text asset. The Image will only act as though it is inline with the text.

How do you wrap text around a rectangle?, Fluid layout for Unity UI - These are what I'm looking for. However, no suggestions have been posted in them.

I've explored the idea of using multiple TextMesh Pro UI Text Objects, with each one acting as a fragment of the complete text area. However, this isn't the same as wrapping the text around the Image. For dynamic text, if I pull content from one text area and push it into the next area, this will conflict with the Auto-Sizing functionality and cause unequal font sizes.

Another possibility is that I could insert characters one at a time, check to see if adding another character would result in a collision with the image, and add System.Environment.Newline to prevent this. However, I worry about the potential performance issues from dealing with large amounts of text.

TextMesh Pro Documentation - The TextMesh Pro Documentation has some tools for finding word wrap points, but I haven't figured out how to implement a means of comparing this to an anchor position of another object.

like image 392
Coalescence System Avatar asked Mar 23 '18 08:03

Coalescence System


People also ask

How do you run text around an image or object?

Navigate to the Text Wrap panel, select Window > Text Wrap. Import the image and prepare the text that you would want to wrap around a subject. Select the image, and from the Text Wrap panel, select Wrap around object shape . Select Wrap around object shape icon.

Which layout option will make the text flow around the image?

To wrap text around an image: On the Format tab, click the Wrap Text command in the Arrange group. Then select the desired text wrapping option. In our example, we'll select In Front of Text so we can freely move it without affecting the text. Alternatively, you can select More Layout Options to fine tune the layout.

How do I get text mesh pro in Unity?

1. Using either the GameObject dropdown or right-clicking in the Hierarchy window, select UI > TextMesh Pro - Text. 2. The first time you use TextMesh Pro (TMP) in a project, Unity will offer to import the TMP Essentials and Examples & Extras packages (if you haven't already imported the TextMesh Pro asset package).


1 Answers

enter image description hereThis can be accomplished with TextMeshPro's "Linked" overflow mode. See attached picture for an example. Essentially, you'll need to make two TMP objects and adjust the layout for each of them appropriately. Then:

1) change the overflow mode of the first one to "Linked" using the dropdown in the inspector.

2) place the second TMP object as the reference in the field that appears.

like image 124
VVander Avatar answered Sep 21 '22 14:09

VVander