Hello, I'm using a TMP text in a 2D game and I have a problem where each time I update the text value, the new value is displayed on top of the previous one, for example, Turn 2 is drawn on top of Turn 1, making the 2 and 1 mixed up, and it does that until the number is a mix of 1 to 9 and become kind of a white square. I check in the hierarchy at runtime there doesn't seem to be more than 1 instance of the TMP object (it's not even instantiated by code to begin with). I tried a lot of things like clearing the text before updating it, calling a refresh after updating but nothing works. Any idea?
#Updated TMP text is displayed on top of previous value
1 messages · Page 1 of 1 (latest)
Sounds like the frame data isn't being cleared? Though that's not really some exposed parameter with canvas overlays if you're using one
I'm sorry I'm a beginner with Unity, only done the 2 Roguelike tutorial and started working on a similar personal project. Here are some of my settings, please ask me if you need me to show any other elements 🙂
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Camera-clearFlags.html
I can't expect this would be the reason as the canvas should be independent but I'd check if for some reason you're setting the flag here to not clear on the main camera.
Not really seeing anything about refreshing the canvas in the API
You are setting a solid background type with 0 alpha, but I don't really think that implies anything as a main camera.
Oh I found the problem I think! It was because of this setting:
My suggestion is work up from the bottom. Make a new scene with a skybox and see if you can get a canvas going and without issue. Then try changing few things at a time like the skybox
I use it to have some black borders around the map to put my texts:
If I reset it to default values, the text is correctly updated:
But then I lose my UI space
That's actually more confusing to me. Perhaps the canvas isn't in charge of refreshing its frame data, and the full rasterization of that frame data is up to the main camera?
Because this would imply that the text outside of the camera rect is uninitialized (sure), but the canvas not clearing on the next frame doesn't really make too much sense to me
I think it's not clearing the previous framers out of it's viewport or something?
That's what it seems.
I need to find a better way to put my UI in the game I think
I mean it makes sense I guess. The camera probably checks the space it occupies and clears it each frame, but the canvas shouldn't care and leaves it up to the camera
Mhhh maybe there's an option for that somewhere, now that you helped me pinpoint the problem I'll try to find something