how can i rotate 2d gameobject 90 degrees at a time with UI buttons?

Hi i’m new to scripting and i’m working on a small 2d game but is a bit confusing
i want to rotate a 4 pointed star 90 degrees every time i push one of the two UI Buttons
i have 2 UI buttons for rotating to the right or to the left
is there a way to only rotate the gameobject 90 degrees with every button tap
for instance if i want to rotate it 180 degrees i’d have to press 2 times one of the buttons
up until now i’ve been able to make the cube rotate but not to limit the rotation
thank you

Hello. I must say you did not look for the answer by your own in google, because is one of the most simple things to do: Rotate an object and assign a fucntion to a button.

First, create a script and a fucntion that rotates the object

public void RotateTheObject()
{
Code
Code
Code
}

Then attach that script to some object in the scene (can be the object itself, but is not necessary)

Then create the Button in a Canvas.

Then just assign the function to the button (llok for tutorials for this)

Bye

hi, thank you @tormentoarmagedoom for you reply, as i mentioned before in the description, i got the gameobject to rotate with my 2 ui button, what i don’t know what to do is to have the rotation stop after 90 degrees

i used the crossplatforminput from unity standard assets with script on every button not the on click solution

using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;

public class PlayerScript : MonoBehaviour
{

public float rotSpeed;

public float rotation;



// Start is called before the first frame update
void Start()
{
    

}

// Update is called once per frame
void Update()
{
    rotation = CrossPlatformInputManager.GetAxis("Horizontal");
    transform.Rotate(0, 0, rotation*rotSpeed);