I'm running into an issue with GUI.Label in Unity3D. If I display some text on the screen and display that EXACT same string 1 pixel down and 1 to the right, it works correctly 99.9% of the time:
var old=GUI.color;
var shadow=rec;
shadow.x++; shadow.y++;
GUI.color=Color.black;
GUI.Label(shadow, txt, style);
GUI.color=old;
GUI.Label(rec, txt, style);
I've had this same code for years but I just recently discovered that a particular string will wrap text in the wrong place on the shadow text, even though they both have the same width in their rect's and same style. What's even more strange is it won't do this every frame. The text appears when I hover over something with my mouse and moving the mouse slightly will cause the shadow string to go back & forth, wrapping two different ways causing the shadow text to not coincide with the normal colored text.
Not an edge-of-screen issue either. I'm using 2020.2.1f1.
Thanks in advance!
Related
I'm kinda a noob at lisp and i'm doing a little project that aims to change the height of a text, color, and also put the text inside a rectangle, but everytime i call the txtedit function, the text changes correctly but the rectangle is forming around the initial size of the text, seeming to be a problem with the x axis, but on the second try on the modified text, it works ok if I input the same height , any tips because i'm kinda stuck?
how it looks after i call the function////////
the code
I'm working on a mind map editor in which the user can draw boxes and write text in them. However, the TMPro input fields I'm using in those boxes have extra-wide caret when I type in them, and changing the fonts didn't solve the problem. Here are some images of the issue:
The caret is so wide that it can push the text inside out of the box:
I tried to lower the caret width in my script, but it's an int and has already been set to 1. Can you give me some possible reasons as to why this is happening?
I solved that problem by multiplying width+height of my inputfield by 100 and dividing its scale by 100.
Don't forget to increase the font size significantly.
I am working with Unity's UI.Text, where I want to show a counter that goes up by 1 every frame. So in Update(), I simply do
count++;
countText.text = count.ToString();
However, instead of the text field getting replaced by the number, the number is drawn on top of the previous number.
I have used UI.Text multiple times before, and never had this issue. What could possibly be happening? Thanks!
You need to add a Camera to your scene. (It says "Display 1 - No cameras rendering" in your screenshot).
Menu -> GameObject -> Camera
Without a Camera and just a Text, what you described will happen - Text will not be cleared between Update calls.
Edit: as per Pluto's comment, also check that Camera's Clear Flags setting is set to Solid Color or Skybox, and not Don't Clear.
Alright, I do not know how to fix this and only ran into this problem after trying to put in some longer text on a UI Text component. I have tried both pasting a value into its Text attribute through the Unity editor, and setting its value programmatically like this:
t.GetComponent<Text> ().text = "This is where meat, fish, and [...] (long text)"
Because Horizontal wrap is on, the text wraps when it reaches the edge of the available space.
However, the text displays backwards. Meaning, the start of the paragraph is at the bottom, and bottom at the top. Taking off wrap fixes this, but then the font size has to be really small (or it won't all be visible), and it can't form a normal paragraph because it has to... you know... wrap.
Is this a bug in Unity?
This is what happens - as you can see, it is displayed backwards:
The negative Line Spacing value is what is causing the issue here:
When the value of this field is less than 0, the lines will actually be arranged backwards, leading to the behaviour you're currently encountering. Just change the value to a positive number to have the text display correctly.
So I have a grid in Zkoss with a certain amount of columns. One the first row I place two labels which fill the first two columns (as expected).
I've written their style so that they don't have change color when you hover the mouse over them however one of the columns label is much bigger than the other and when I hover the mouse over the smaller label the area around which isn't filled by the text goes to white.
ZKFiddle example
I'm going insane around this as I'm simply unable of making that area have the same background as the label.
Like I already said in your duplicated question.
CSS is responsible and you just need to search with developer tools.
This update to your fiddle tooks me 2 min.
The changed thing :
.z-row:hover > .z-row-inner, .z-row:hover > .z-cell {background:red; !important}