- Home /
Text gets hidden on frames where other text is behind it
I have text bubbles, that normally display properly. There is a bubble graphic, and a child text object displayed at a higher layer. the text displays in front of the bubble and is readable, except in this certain scenario, that I'm trying to solve.
I also have pop-up damage counters, that are text objects. These appear behind the text bubbles. If there are any of them alive in the scene though, the text inside the text bubbles disappears...
Here you see the empty text bubbles, and one of the red pop-up damage numbers. (The red "1" is actually 6 pixels tall, so the top 2 pixels are being covered by the text bubble)
If I move the text bubbles though, I can see the text displayed behind them... (what the hell?!?) Yet, when all the pop-up damage is gone, the text in the text bubbles returns to back in front of the bubbles...
Here I've moved the bubble to the side, and the vanished text is there, hiding.
As a test, I moved the pop-up damage to a layer ABOVE the text bubbles. This made the text bubble text appear again... The problem being, that I didn't want the pop-up damage appearing in front of the text bubbles. (not letting me attach a 3rd image sadly)
I also tried swapping the order in the hierarchy, of the parent objects of either my pop-up text or the dialog text-bubbles. This didn't seem to change anything.
So my best guess about this is that it means that text is only displayed on one layer ever, and the newest text sets that layer... This sounds crazy to me though. Can anyone set me straight on what is going on?
Each text object is child of an object with a canvas, and each of those objects is also child of an object with a canvas, and so on all the way to the top canvas which is set to worldspace, and the camera set to orthogonal.
The Text bubbles are code-instantiated prefabs, where the text is changed at the time they are instantiated. The same is true of the pop-up damage, but the damage spawns much more frequently than the text-bubbles. the pop-up damage lasts for only a second or so, before vanishing. When all pop-up damage is gone, the text bubble text is drawn properly again.
I've run out of ideas to try! Any ideas are appreciated!
Demonstration of the text-bubbles working, in the condition that the pop-up damage is set to a layer higher than the text-bubbles.
Good day.
The position in the hicheracy is important. In the same level of hicheracy, lower objects will be shown over higher objects. I dont know if it's your case
Thanks for the reply! I forgot to mention that one of the things I tried was swapping which was higher in the hierarchy... but that didn't work either. It is good advice though.
Answer by NotHalfBrad · Apr 12, 2018 at 04:44 PM
I'm not happy with this answer, but I found a workaround...
I changed one of the prefabs to use a TextMesh, instead of Text, and now they both play nice with one another. I don't understand why this solution works, or why I couldn't have many different types of Text onscreen.