- Home /
GUI Text/Buttons acting strangely despite similarities to normal-acting UI elements
I created a pause menu the other day, which I think came out pretty nice. I followed the exact same procedure - in regard to using Unity's UI system and laying out my UI elements in the scene - when creating my start menu, but for some reason there is a myriad of strange behavior occurring with my start menu. I'm using TextMeshPro for both my buttons and text.
Here is my pause menu. Notice how the scene and game views have mirrored behavior; I hover over the "Resume" button in the game, and it's highlighted correctly both in the game and in the scene:
Now for the start menu issues. Please note that these issues are happening in Play mode. The first thing I'm noticing is that my text is distorted in the game view, but not in the scene view:
I should mention that I created the buttons in the start menu from the same prefab that was used to create the buttons in my pause menu. How could their behavior differ? Here are two other screenshots showing the button component setup, and a weird highlighting issue (notice the discrepancy between the scene and game views):
https://imgur.com/a/39IQzT5
Once I hover over my buttons in the start menu, they remain permanently highlighted.
All the canvases in my game are set to Screen Space: Camera, and each canvas has its own camera; all canvases are at the exact same position; they are also set to Scale With Screen Size, and all the screen reference sizes are the same. I have an event system as a child of each canvas.
I'm fairly certain I'm overlooking something very simple, but I've remade my start menu from scratch several times, making sure, to the best of my ability, that there are 0 differences between the two menus; I even refrained from copy/pasting component values because I was noticing that there were some inconsistencies from doing that.
Answer by Dalsia · Sep 01, 2019 at 07:28 AM
Okay, this is weird but I figured out how to fix the issue.
I have to set my camera to have some kind of background; previously I had been using "clear depth" in the clear flags setting. I'm not sure why this matters, though, because my pause menu camera, and every other UI camera in my game, have their clear flags set to "depth only" and have no issues rendering any UI.
I would greatly appreciate an explanation of this if someone knows what's going on.
Your answer
Follow this Question
Related Questions
Text Mesh Pro : Unable to use pull down menu inspite of Distance field 16 0 Answers
Predict Text Width of String 0 Answers
Changing Text Mesh Pro Text in World Space using C# Script 0 Answers
Scrollbar Movement Issue 0 Answers
Why does my TMP inputfield text disappears when I rotate It, why using a world space camera 0 Answers