Rotate GUI Button


I was trying rotate a GUI button, but found nothing!

Maybe using changing GUI.matrix? don’t know! already try and the only result was:

“GUI.matrix - the matrix needs to be invertible - did you scale by 0 on z-axis?”.


What you can do is use GUIUtility.RotateAroundPivot to rotate your GUI before you draw the thing you want rotated, then draw the thing you want rotated, and then use the rotate function again to rotate back to the original rotation before drawing the rest of your GUI. Hope this helps!

This is only going to allow you to rotate the GUI in 2 dimensions. If you want to rotate it in the third dimension you will need to use the GUI.matrix property.

You need to learn how 4x4 matrices work and how they affect things in 3D before trying to get this to work.

You can use this function to get the matrix that you want for your rotation.

GUI.matrix = Matrix4x4.TRS(t, r, s)

t = translation
r = rotation
s = scale

Here’s more information on Matrix4x4.TRS

Then you can set GUI.matrix to this matrix.

I suggest saving GUI.matrix before doing this so you can set it back when you need to.