Since I stepped up to Unity 4.1.2f1, I’ve noticed that when I scale the GUI using GUI.matrix, GUILayout buttons don’t hover correctly when the cursor is over them unless I’m at the actual resolution to which I’m scaling the GUI.
It’s like the rect for the button isn’t being calculated correctly with the matrix applied, so the hover effect happens when the cursor is at a location slightly offset from the visible bounds of the button.
Here’s the code where I apply the matrix to the GUI:
public const float ScreenWidth = 800;
public const float ScreenHeight = 600;
void OnGUI()
{
Vector3 scale = new Vector3((float)Screen.width / ScreenWidth, (float)Screen.height / ScreenHeight, 1);
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);
// Draw gui stuff here
}
Is this a bug? Or am I doing something wrong?
I just noticed this too. Do you know if it was working prior to 4.1.2f1? I'm asking because I found a similar post back in 2008 and was wondering if they ever fixed this issue.
– glapoint22I know it was working prior to 4.1.2f1. We scale all our GUIs so the problem was immediately noticeable when we stepped up to this version. I have seen the posts from 2008 and they do seem to talk about the same type of issue, but from what I can tell the issue was corrected previously and has reappeared in this latest version.
– rmarra07I've the same issue :( Here is my posts: http://answers.unity3d.com/questions/447204/wrong-buttons-hotspot.html and here: http://forum.unity3d.com/threads/180473-Wrong-Buttons-Hotspot?p=1233673#post1233673 I hope that this will be fixed soon ..
– Luca91Still having a similar issue in Unity 5.1 where enum popups aren't scaled nor at the right position when scaling. Pretty nasty. Even have to scale the clipping zone manually with a hack as it was scaled with it.
– Seneral