- Home /
rotating GUI texture by angle
I am currently trying to display a rotating needle gauge to the player, and have the gauge show how far left or right of center the user is. I can mathematically find the needed angle the needle needs to be at, but as I am trying to display this through GUI I don't know how to rotate a texture/image in GUI.
How do I rotate a texture drawn to the GUI?
Answer by robertbu · Jul 25, 2013 at 05:45 PM
You cannot rotate a GUITexture. You can rotate a texture drawn with GUI.DrawTexture(). See the answer by @duck here for an example:
http://answers.unity3d.com/questions/11022/how-to-rotate-gui-textures.html
If you Google "RotateAroundPivot Unity3d," you will find a number of other questions dealing with rotating a GUI drawn texture.
probably going to need to mutilate this to get it to rotate about the bottom center apposed to middle_center, but thank you none the less. if I can get a full case switch of the change in pivots I might through it to the Wiki for convenience.
As an alternate to changing the script, change the texture. That is make a texture 2x taller than needed and have the base of the needle end in the center of the texture with the rest of the texture transparent.
Answer by aldonaletto · Jul 25, 2013 at 05:51 PM
You can't rotate a GUITexture, but in the GUI system it's possible to modify the matrix so that GUI stuff is rendered at a given rotation, scale or offset. The easiest way to rotate a texture is by using GUIUtility.RotateAroundPivot - take a look at this question for more details.