While adding a canvas and then text into a gameobject, Canvas and text size problem - unity3d

I am working on a 2d project with unity engine. (I am a newbie)
As you can see in image I already have a canvas for UI elements but also I have gameobjects under player element. I want to add text inside "govde" element. but when I add it;
at left bottom you can see my game. but canvas and text size is HUGE.
I dont know what is wrong with my game or canvas but I could not solve this.
By the way my gun works well so there are no errors in game. here is a photo of game scene;
Thank you for any kind of help. Have a nice day:)
EDIT : I Wanted to show the text box I wanted; please consider the numbers are so small. What I am asking is when width:2 and height:1 ok my textbox fits inside that car but since it is so small, i cannot show even 1 characters inside text box even if I make font size : 1. My english is not perfect sorry if I make any mistake. Here is picture;
and IF I Make bigger to everything, They don't fit to my game screen. I tried to move camera to far away but that did not changed to my Game Screen.
LASTLY: When I add my a text inside my UI CANVAS, it perfectly fits. But when I add same textbox to game object called Player as I needed, it is TOO BIG
SOLUTION : For anybody who deals with same problem try to create a text object inside a UI CANVAS, after that create another canvas inside game object. And lastly, drag textbox into second canvas . That solved all my problems. My second canvas is still huge and when I make it smaller my textbox gets smaller and smaller so I cannot use it again but I let canvas to be huge, no problem for me at all. Thanks for helps.

The text you created is the tiny black ‘New Text’ above the word basla. The canvas isn't actually viewable, you can add a ‘Panel’ underneath to confirm its size.
edit set font size and change width and height of text
keep scale at 1,1,1, track all the parent scale of each parent object, they do multiply in scale as you go down, so if one parent has scale 2,2,2 and its parent has scale 3,3,3 by the time you get to the text at 1,1,1 its scaled to 6,6,6 so keep this in mind and reorganize you hierarchy as needed

Related

Text becomes invisible behind background canvas Unity

I just added 3D Text on my scene and it is invisible on the background of Canvas, that is "Render Mode: Screen Space - Camera". How i can make it visible on background of my canvas?
There are 2 ways to fix this:
Change the Sorting Layer of the obstructing object to be one behind that of the text, or change the Order in layer of the obstructing object to be lower than that of the canvas.
OR
Create a new canvas with a higher Sorting Layer (you may need to create a new one) or Order in Canvas and place the text in the new canvas.
As an example, here I have my normal text in a lower canvas, but I created an overlay canvas for text that absolutely must go above everything else.
I find that the second solution is a better general solution for the issue, as in the first solution you have to change the layers for every object in the scene that might obstruct your text.

Scale UI buttons and images with screen size

I ma developing a game for unity and i want to be able to scale my buttons and UI elements to fit different screen sizes. Please how can i go about this? I have tried scale with screen size and it doesn't seem to help me. Is there a script i can use for this?
You will want to use a canvas scaler for this.
You simply attach this object to your canvas parenting your UI elements and it will scale them acordingly.
You will also want to make sure your UI elements are anchored correctly so that they stretch with their correct anchor point.

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.

Canvas too big for the camera in Unity

I have created a 2D game with an orthogonal camera and using 16:9 display size.
I dragged my background image onto the hierarchy (it's about 2048x1152) and then set the camera size to be 22.5, which made it fit the background perfectly and displays just right.
However, when I add a Canvas for a UI it is absolutely giant, about 100 times bigger. It only becomes 'normal' size with respect everything else added when I set the camera to its default size of 5. So when I add a small graphic, it too becomes giant.
I'm simply following a book I read and I'm not doing anything to deviate.
Am I doing something wrong? Below is what I mean. The background image is the little image in the bottom right and the outlined rectangle is the canvas with a small graphic added.
Thanks.
To force your Hierarchy Canvas UI to the same resolution as the Camera View in your Unity Editor Scene window resolution (i.e. not ridiculously massive), or in other words get the Canvas to fit into the Camera size in the Scene, do the following:
Set the Canvas component's Render Mode to Screen Space - Camera.
Make sure you select or drag the relevant Camera from the Hierarchy to the Render Camera field in the Inspector.
You should use the Unity canvas for this along with the canvas scaler component. If I'm not mistaken it will scale all elements relative to the screen they are viewed on.
The canvas scaler allows you to match the scaling based on a preferred viewport size which is a life saver.
However this may not fit you needs perfectly as it would mean that the background element would become fixed. So if you wanted to pan the element you would need to move it's x and y elements within the canvas.
Hope that helps?