Screen Dimensions Changing on Input and Breaking UI
I am making a turn based strategy game and creating a UI that follows the units. I do this by obtaining the world position of each of the units, calculating the screen position using WorldToScreenPoint, and then positioning the UI at that point on the screen. This was working fine until I opened Unity recently and found that WorldToScreenPoint was returning different values based on whether Unity was receiving input or not (i.e. mouse movement, mouse clicks, keystrokes etc).
After some investigation I found that the values for the screen size were changing (i.e. Screen.width and Screen.height) whenever unity detected input, though there is no noticeable visual change (the screen appears to stay the same size). The value that the screen size is changing to when input is detected appears to be the correct value because the UI looks to be positioned correctly, and positioned far from the unit when no input is detected.
Are there any ideas as to what could cause this?
If this is relevant, I am using version 2019.2.5f. I also installed a Windows update between when the UI was working correctly and when it broke. Is there any know bug that might cause this?
Answer by HectorSmoke · Mar 06, 2020 at 09:49 PM
Just updated 2019.3.4f1 and the issue has gone away. Might have been an incompatible with the older version of Unity I was using and my windows update. Don't know for sure though.
Your answer
Follow this Question
Related Questions
How to calculate ui image size in world space? 0 Answers
Check if EventSystem is in InputField 1 Answer
NumericUpDown input field 1 Answer
Canvas not rendered by camera 1 Answer
Vector move based on screen size 0 Answers