- Home /
Disabling/enabling canvas component causes weird text/font problems on Android
I decided to stop using SetActive on my game objects. Instead I started disabling/enabling the Canvas components since this prevents the CPU spikes caused by SetActive.
After my changes, I tested on Android. For some reason, re-enabling a canvas component completely screws up the text that's on the canvas! The text becomes blurry, some text disappears, even the ToString("F2") on my numbers get rounded to 1 decimal instead! When I select a dropdown option, some unrelated text on the canvas disappears, etc. Everything is screwed up!
If I force a redraw by changing the device's orientation (and back again), the text is no longer blurry, but it doesn't bring back the disappearing text.
These text/font problems only show up on canvases with a canvas component that was just re-enabled. So why does re-enabling the canvas component screw up all the text on it? And how do I fix it?
Oddly enough, the problem doesn't occur when using CanvasGroups ins$$anonymous$$d.
So I ended up replacing...
GetComponent().enabled = true;
to
GetComponent().alpha = 1; GetComponent().blockRaycasts = true;
... and the opposite to disable canvases.
There really shouldn't be any reason for this problem, but this workaround fixed most of the text issues.
I still hope that the Unity $$anonymous$$m will look into the issue.
Answer by Potter-Solutions · May 03, 2019 at 03:30 AM
Check out this post about the Canvas Scaler. Sounds like this is the root issue.