Operation in loop as long as a GUI button is pressed down

Hi

I’ve found answer:

and I try do do in similliar way.I have inside OnGUI():

GUI.Button(new Rect(xOffset,yOffset,buttonWidth,buttonHeight),"LEFT");

and inside Update():

if(Input.GetButton("LEFT")) transform.Rotate(0,20*Time.deltaTime,0);

but that does not work :confused: Why?

The RepeatButton does the trick:

if (GUI.RepeatButton(Rect(xOffset,yOffset,buttonWidth,buttonHeight),"LEFT")) {
    //repeating code
}

Your two pieces of code are completely unrelated. In the default Unity text editor, highlight GUI.Button and press F1. Read that. Then do the same for Input.GetButton