- Home /
GUI Rotation and Depth problem
Hello everyone.
I'm using this simple trick to constantly rotate a GUI.DrawTexture element.
// Use this for initialization
void Start () {
GameObject tweenObject = new GameObject();
tweenObject.name = "tweenObject";
pivotPoint = new Vector2(Screen.width/2, Screen.height/2);
if (Input.GetKeyUp(KeyCode.Return)) { //if Enter is pressed
}
}
// Update is called once per frame
void Update () {
rotAngle = iTween.FloatUpdate(rotAngle, rotAngle+50, 1);
}
void OnGUI () {
GUI.DrawTexture(new Rect(Screen.width/2-100, Screen.height/2, 200, 100), LevelUp);
GUIUtility.RotateAroundPivot(rotAngle, pivotPoint);
GUI.DrawTexture(new Rect(Screen.width/2-100, Screen.height/2-100, 200, 200), StarBurst);
}
What I'm trying to do, is rotate the StarBurst texture and display the LevelUp texture on top of it without rotating.
Currently the LevelUp texture is not rotating but is behind the rotating StarBurst texture.
If I change the order so the LevelUp texture is drawn second, then it does appear in front but it also rotates together with the StarBurst texture.
Is there anyway to fix this? (without creating another script to draw the non-rotating part)
Thanks!
Answer by robertbu · Apr 15, 2013 at 07:02 PM
Save and restore the matrix. Take a look at OnGUI() funciton of @duck's answer:
http://answers.unity3d.com/questions/11022/how-to-rotate-gui-textures.html
Your answer
Follow this Question
Related Questions
Limit GUI Rotation? 2 Answers
3D effect with new UI system 1 Answer
Position jitter when using GUIUtility.RotateAroundPivot 0 Answers
Look at around one axis in local space 1 Answer
Rotate to Original Z Rotation 3 Answers