Trouble with using Text Mesh in Unity - unity3d

So the problem is that I want create such an idea. There are a table and a sheet of paper (just a Plane). I want to place some text on this sheet of paper. I read about Text Mesh and I thought that I would use it but I had a problem about it. I need to limit my text on this sheet of paper but I haven't found any borders I can place there. How can I set borders to Text Mesh? Or are there any decision I can use to handle this situation?

TextMesh does not have borders
Instead, you are probably interested in a World Space Canvas and using UI text instead. Unity has a great tutorial in the manual for setting up a world space canvas, which pretty much amounts to "set the Canvas to world space, decide on a resolution, decide on a in-game size, and position it."
For text, you actually have two options: UI Text and Text Mesh Pro. TMP used to be an asset on the asset store, but Unity has integrated it into a semi-standard package now (just create a TMP object and you'll be prompted to do the importing). TMP has several additional features and options that standard UI Text does not have, including in-line sprites, margins, text alignment, better rich-text, and so on. It might be overkill, but it is available.

Related

2D sprite problem when setting up an instant messaging UI

I'm new to Unity and to game development in general.
I would like to make a text-based game.
I'm looking to reproduce the behavior of an instant messenger like messenger or whatapp.
I made the choice to use the Unity UI system for the pre-made components like the rect scroll.
But this choice led me to the following problem:
I have "bubbles" of dialogs, which must be able to grow in width as well as in height with the size of the text. Fig.1
I immediately tried to use VectorGraphics to import .svg with the idea to move runtime the points of my curves of Beziers.
But I did not find how to access these points and edit them runtime.
I then found the "Sprite shapes" but they are not part of the "UI",
so if I went with such a solution, I would have to reimplement
scroll, buttons etc...
I thought of cutting my speech bubble in 7 parts Fig.2 and scaling it according to the text size. But I have the feeling that this is very heavy for not much.
Finally I wonder if a hybrid solution would not be the best, use the
UI for scrolling, get transforms and inject them into Shape sprites
(outside the Canvas).
If it is possible to do 1. and then I would be very grateful for an example.
If not 2. 3. 4. seem feasible, I would like to have your opinion on the most relevant of the 3.
Thanks in advance.
There is a simpler and quite elegant solution to your problem that uses nothing but the sprite itself (or rather the design of the sprite).
Take a look at 9-slicing Sprites from the official unity documentation.
With the Sprite Editor you can create borders around the "core" of your speech bubble. Since these speech bubbles are usually colored in a single color and contain nothing else, the ImageType: Sliced would be the perfect solution for what you have in mind. I've created a small Example Sprite to explain in more detail how to approach this:
The sprite itself is 512 pixels wide and 512 pixels high. Each of the cubes missing from the edges is 8x8 pixels, so the top, bottom, and left borders are 3x8=24 pixels deep. The right side has an extra 16 pixels of space to represent a small "tail" on the bubble (bottom right corner). So, we have 4 borders: top=24, bottom=24, left=24 and right=40 pixels. After importing such a sprite, we just have to set its MeshType to FullRect, click Apply and set the 4 borders using the Sprite Editor (don't forget to Apply them too). The last thing to do is to use the sprite in an Image Component on the Canvas and set the ImageType of this Component to Sliced. Now you can scale/warp the Image as much as you like - the border will always keep its original size without deforming. And since your bubble has a solid "core", the Sliced option will stretch this core unnoticed.
Edit: When scaling the Image you must use its Width and Height instead of the (1,1,1)-based Scale, because the Scale might still distort your Image. Also, here is another screenshot showing the results in different sizes.

Why there is a difference in the text size when show it in one Text ui and another Text ui with the same settings?

The post is a bit long but I tried to explain everything that is connected to the issue.
This screenshot is of the parent ui texts canvas.
This is a screenshot of the description ui text the text in the game looks very big the fonts are very big and stretched.
This is a screenshot of the scene text Image settings :
And the scene ui text settings :
This is a screenshot of the scene ui text when running the game from the exe build file :
And last the description ui text in game when running the build exe file :
How can I make some ui text that will be display the text the same in all the cases something that will be readable nice not too small and not too big ?
In the scene text the text is smaller because I wanted the text to be a bit under the player mouth. In the description text is a bit bigger but then everything get messed.
I think I want the text to be shown like in the scene ui text in all the places. I think the size is fine. but not sure how to do it.
There's a couple of things here that should get your text working nicely across the board.
Firstly, at your root Canvas object, you'll usually have a Canvas Scaler there. The default of "Constant Pixel Size" is often exactly what you don't want. I normally have it set to "Scale With Screen Size", and then set the resolution to 1920x1080. I do that because 1920x1080 (16:9) is the standard Full HD screen size, so you can bet that most of your screen layout is going to look the same across most displays.
The second suggestion would be to use TextMeshPro. If you haven't already got it installed through your Package Manager, then you can find it there. Here's the docs for that. It's FAR superior to the standard Text element and you'll notice less issues trying to get your text looking correct. It's usually just a matter of adding the TMPro_Text UI component to the same object your Text component was originally on (removing the original Text component of course).
I would also leave all scaling for all of your UI items set to (1, 1, 1) where you can and let and scaling be done by the Canvas Scaler. The text elements can certainly be left at (1, 1, 1) and just change the font size.
Once you get these three things sorted, your text should be the same across all of your pages, and devices.
This due to Scaling Rect Transform Component
to solve this don't scale up or scale down UI Elements {Image ,Text, ... just keep Scale 1,1,1 }
First I recommend You to see This to understand this Component
https://www.youtube.com/watch?v=FeheZqu85WI&t=6s
Now to Solve your problem
Set Scale of Description Image (1,1,1)
Set Scale of Description Text (1,1,1)
Do 1,2 with Scene Image, Scene Text
Change Width , Height of{Description Text, Scene Text} with small values 900*400

Text sizing issues when using small scale text mesh in Unity UI

When using textmesh to add a label to my prefab gameObject in Unity, the text appears really squashed and not filling the space properly and I can't seem to figure out how to make it appear normal. I had the same issue using plain text.
Even if i make the canvas way bigger than I want it just to test, the text is all squashed and distorted
I am using a canvas and my scaling is quite small
Update:
Try to add a CanvasScaler component to your container Canvas gameObject (add it only if it is not there yet).
https://docs.unity3d.com/Manual/script-CanvasScaler.html
It has some properties but the most important is the Reference Pixels Per Unit set it to a higher, or a much higher number.
If your container Canvas has its Render Mode in Screen Space - Overlay, then your text will look little "stretched" - as your picture shows it. If you modify the scale mode to anything else, then this will be alright.

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:
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.
This 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.

How to add text to surfaces of complex 3D models in Unity3D?

I would like to add small text, less than 10 letters to the surfaces of complex 3D models, such as a person model or a building.
One way is to add the image texture to a material, and then add the material to the model. But by this way I can not control where the text will be placed. For example, if I use the material with a text texture to a cube, all the 6 surfaces will display the text. This is what I don't want it be. I just need the text displayed only once, wherever it is.
What I need is just to add some text on the surface anywhere, even randomly.
Can I realize this by Unity itself without other softwares like Maya, Photoshop?
Thanks!
Try using a text mesh and a text renderer ...
http://docs.unity3d.com/Manual/class-TextMesh.html
As always with unity there's a tool for that :)