Rotate object with a gui texture button

i have an object and 2 gui texture buttons. i want to rotate my object by pressing the 2 buttons (one-left, one-right).

ideas ?

It’s simple, use GUI.RepeatButton and transform.Rotate - like this:

var imageLeft: Texture2D; // drag the left button image here
var imageRight: Texture2D; // right button image
var speed: float = 60; // rotate speed in degrees per second
private var rotLeft = false; // object rotates left if true
private var rotRight = false; // object rotates right if true;

function OnGUI(){
    rotLeft = GUI.RepeatButton(Rect(10,10,200,200), imageLeft);
    rotRight = GUI.RepeatButton(Rect(230,10,200,200), imageRight);

function Update(){    

    if (rotLeft) transform.Rotate(0, -speed*Time.deltaTime, 0);
    if (rotRight) transform.Rotate(0, speed*Time.deltaTime, 0);

I don’t know which value Time.deltaTime assumes inside OnGUI - it should be the time since last OnGUI, but I’m not sure. To avoid problems, I placed the real rotation in Update and used two control booleans (rotLeft and rotRight) to communicate with OnGUI.

try doing something like this

function OnGUI(){
var RotateSpeed:float;   //speed to rotate at
var MyObject:GameObject; //the object to rotate
if(GUI.RepeatButton(SomeRect, sometexture)){
if(GUI.RepeatButton(SomeOtherRect, someOthertexture)){

if you want the code in C# ask me, and I dont know if it works, i’ll test it when I get home for you

can i do this without rect ?


I would like both panels (rotate and zoom) to look the same (as zoom does, witch was done with gui textures).