Hello.
I’m trying to make my GUI resolution independant, following the example from the 3D platform tutorial.
The GUI now looks nice on different resolution, all except the one I rotate. I have a leaver that rotates around a pivot point, and the rotation is only correct in one resolution.
//m_virtualHeight = 768
GUI.matrix = Matrix4x4.TRS (new Vector3(0, 0, 0), Quaternion.identity, new Vector3 (Screen.height / m_virtualHeight, Screen.height / m_virtualHeight, 1));
and when i rotate my leaver
Matrix4x4 Old = GUI.matrix;
GUIUtility.RotateAroundPivot ( m_pinAngle, m_pivot );
if( m_difficultyPin )
{
GUI.Box( m_pinRect,m_difficultyPin );
}
This works fine when I run in 1024 * 768.
I don’t know hot to calculate the pivot point so it’s resolution independant.
Once the GUI.matrix has been given a new transform:
GUI.matrix = Matrix4x4.TRS ( new Vector3(0f,0f,0f), Quaternion.identity,new Vector3 (Screen.height / nativeVerticalResolution, Screen.height / nativeVerticalResolution, 1));
the GUIUtility.RotateAroundPivot stops to work. The pivot point is correct, but the rotation is all wrong.
I also have the problem.
I use GUI matrix to fit all my GUI nicely in any resolution.
But the GUIUtility.RotateAroundPivot doesn’t work in any resolution. The pivot point cannot adjust by itself in other resolution.
Any solutions?
facing the same problem,
multiplying (Screen.height/Screen.width)*(1024.0/768.0) to the m_pinAngle takes care of rotation and you need to modify m_pivot coordinates also(as they don’t get scaled by the GUI matrix). So multiplying (Screen.width / 1024.0) to m_pivot’s x coordinate and (Screen.height / 768.0) to y will take care of that.
I did that and the new scaling was a little better but still not accurate when pivotangle is large.
Any idea how to do that?
Thanks
Thanx MasterYoda! that did the trick for me… wasnt using large angles thogh… with small angles works great.
Anyway, this should be taken care by unity matrix