- Home /
Screen Resolution Offsets Cursor and buttons
I've notice that if I don't have the max screen resolution in build version of game. The cursor will be where it should be at but when you try clicking buttons, it offsets and you can't click the button directly. Is this a bug or a programming error?
Answer by Aggrojag · Jun 17, 2015 at 06:29 AM
http://issuetracker.unity3d.com/issues/button-position-is-wrong-on-fullscreen-player-which-aspect-ratio-is-different-then-monitors I believe it's a unity bug, as I'm experiencing it too. I did find this bug report.. I suggest upvoting it as I've tried to find a solution, but have yet to find one myself. Best of luck.
Thanks for showing me this. I have Up Voted the issue.
Answer by Ashkan_gc · Jun 01, 2015 at 05:26 PM
This is not a bug in Unity. This is a programming error on your end. If unity had a bug this important almost certainly people have reported it and they would fix it (assuming unit tests of unity itself doesn't detect such things).
In order to be able to get more help, describe what version of unity you are using, what GUI technology and how you are detecting a click.
I believe the version is 5.0.2. I'm using there GUI system with GUILayout functions. I'm confused with how you're detecting a click. I'm creating the windows and buttons using the GUI and GUILayout functions. Doesn't the unity GUI detect the clicks?
Well then the GUILayout.Button returns true when a click on that button happens so you write if(Guialyout.Button("your buton text") { //Write code for the click event } I advice you to move to the new UI system called uGUI which handles resolutions much better and at first might take more time to create due to not being code oriented but at the end is much more flexible and robust.
I will try that thanks. But since that doesn't solve the current problem I can't have this accepted as answer.
I have tried the new 4.6 GUI System but its not efficient and/or understanding enough for me to use it. I can't get the buttons I made to stretch to fit to canvas or panel. I shrunk the panel and added a button and the text gets shrunk. Doesn't explain how to code the buttons because I have a for loop for button creating that I need in the new GUI.