Fix for text being invisible on first Gameobject.setactive true/false

Was there ever an official fix for UI Text being invisible when it is initially set active true/false? I notice in recent builds that the issue of having text gameobjects set active false then turning them on via code has them active but invisible until I toggle them active off/on again twice

Original Post on Discord

by user 103054507105067008

Do you have a link to the original issue?

by user 103054507105067008

Might be a regression

by user 103054507105067008

Are you sure it’s broken again or are you doing something different this time?

Nothing different to before, I can prepare a repro of this tomorrow, simply a worldspace canvas with a text object as a child of an image, canvas is disabled by default

by user 103054507105067008

Hi @herbst🌵 I have the same issue as well. By setting canvas as off when the scene initiate, gameobject setactive = true when trigger a collider. First trigger, the canvas was not active, then re-trigger, the canvas is back on.

by user 204651044183998464

Found a work around, will be setting the canvas on → off and back on again.

by user 204651044183998464

Thanks for adding to the thread here! We’ll take a look

Just FYI I have run into the same issue trying to instantiate prefabs with a canvas and text

by user 563549194137239552

Wasnt that the exception/error caused during instantiation of a canvas with text or was it another one also?

It was another one as well. The instantiation one was happening when the stored prefabs got created on connect, but there was another issue where the first time i created the prefab the text didn’t show. When i created the second prefab, both the original and the second prefab text showed. What’s weird is that if I put one of the prefabs directly in the scene, it would show up, but instantiating the prefab would still not show until i created the second one.

by user 563549194137239552

Ok weird, thank you! Got a rough idea what could possibly be causing it but need to try

for what it’s worth… while I was messing around with it… I noticed there were similar issues with the text alignment property, and the RectTransform width and height parameter. I could change the recttransform width and height once, but then they were stuck. I never managed to change the text alignment property

by user 563549194137239552

Somewhat related… what I was doing actually was adding text annotations to object… so the prefab had text in it and got attached to objects… I couldn’t figure out why sometimes objects would randomly delete themselves but in the end it was because the text/canvas in the prefab which was billboarded would sometimes touch the barrel in the collaborative networking example and delete because it was touching the barrel… not a bug but a heads up in case this happens to someone else

So as you were moving around using orbitcontrol… the billboarded text would move around to stay facing you and because of it moving it would intersect with the delete box on the barrel

by user 563549194137239552

Dont know if it’s the same issue, but i noticed the text atlas does not include chars of inactive text components. I solved this for now by placing an active debug text somewhere with all the characters I’m using.

by user 334342083445784576

How is your font asset setup? You can define/override the characters that should be included in there

It is definitely not the same issue

okay, sorry for capturing this issue then :slightly_smiling_face:
I just tried to reproduce the issue and it seems to be in some sort of “german language niche” problem ;).
I got a “The character ‘ä’ is not included in the font characters set.” exception, when putting an inactive text component with “äöü” letters in my scene and reactivate it via scripting. These special letters normally do not get build in the atlas it seems.

by user 334342083445784576

I think if you are referring to the default font of unity it only includes the ascii standard characters. But if you import a custom font asset you get to setup the characters manually in the asset that you want to be included as a workaround. Not sure what the best way would be to make the easier (mybe have a global asset that can be used to setup “additional characters” or something like it? But I’m not sure.