I want my GUI buttons to rotate on its own axis.
I have added a few line of code to it.but not getting the rotation in the way I want.
its rotating around the pivot defined by me.Is there any way so that it can rotate on its own axis and nothing else.like gameobjects rotate using transform.Rotate on a particular axis.
here is my code:
using UnityEngine;
using System.Collections;
public class Menu111 : MonoBehaviour {
private float rotAngle = 0;
private Vector2 pivotPoint;
public GUISkin MenuSkin;
bool isrotating = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(isrotating){
rotAngle += 1;
}
}
void OnGUI(){
GUI.skin = MenuSkin;
pivotPoint = new Vector2(Screen.width / 2, Screen.height / 2);
GUIUtility.RotateAroundPivot(rotAngle, pivotPoint);
if (GUI.Button(new Rect(Screen.width / 2 - 25, Screen.height / 2 - 25, 128, 128), "Rotate"))
isrotating = true;
}
}