- Home /
Issues aligning objects to screen points even when aspect ratio changes.
Because the built-in GUI system for Unity is rather dull, I had rolled my own system wherein buttons and text boxes and all that good stuff are really 3D objects.
Game has been in development for many months now and so far my home made GUI system is working perfectly.
Now I've run into a real problem.
I need to make it so that, for instance, one of my buttons must always be on the very left side of the screen. This falls apart when the screen changes aspect ratios, and I'm lost about how I fix this. Getting the viewport percentages doesn't work because 1% from the very left at 4:3 is different from 1% from the very left at 16:9 as far as the width of the gap between the edge of the screen and where the object gets placed.
I've tried all sorts of solutions... I've tried calculating aspect ratios and adjusting horizontal positions based on it (which always results in strange placements), using ViewportToWorldSpace on my GUI camera, etc.
I'm making a PC game, so keeping a table of 30 different possible resolutions and making cases for each one is absolutely not an option. I need a dynamic approach.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
How to make a Keypad for a locked door 2 Answers
Trying to Highlight text in order to copy and paste, but do not want the text to be editable. 1 Answer
Can EditorWindows dynamically display interfaces of other Editor Windows ? 1 Answer