Scaling unity OnGUI to aspect ratio
Author: Aaron King
This week the only thing that was more challenging to figure out was getting custom the custom GUI for the cheat code window to scale correctly with the current aspect ratio. The initial was I was setting things up was hard coding the boarders that the GUI could take up, and this worked fine for setting it up and getting everything working. But the issue came up when we added the ability to change the aspect ratio in game. Since it was all hard coded to be the correct size for just 16:9 aspect when you changed to the larger formats we are offering it became almost to small to even see. And when I added buttons for using the cheats via the same OnGUI call, they where impossible to click on while also knowing what button it was you where clicking on.
The solution that I found was really simple but worked really well in my personal testing of it. I was able to take the current screen dimensions and divide them by a constant factor to set the borders and size of all the GUI. This pertained to not only the display boxes but the text, scroll view for the cheat buttons and the buttons them selfs. This way even if we end up adding in more aspect ratio in the future this side of the code should be able to accommodate for any new aspects with out any more work on my end.
Disavowed
Status | In development |
Authors | King Studio, Devon0033, Mike_Sroka, Michael-W-Smith7 |
Genre | Adventure |
Tags | 2D, Action-Adventure, Metroidvania, Unity |
More posts
- Steam Launch!!!Dec 17, 2022
- Coming to a closeDec 16, 2022
- Project OverviewDec 14, 2022
- Steam StuffDec 13, 2022
- Achievement GetDec 11, 2022
- Controls Remapping AgainDec 10, 2022
- Steam funDec 09, 2022
- Boss Music ImplementationDec 09, 2022
- SteamWorksDec 02, 2022
- Callback Issue with Controller SupportDec 02, 2022
Leave a comment
Log in with itch.io to leave a comment.