There is a UI button, when you click on it, the same button smoothly rotates 90 ° and the rotation stops, when you press the button again, the action is performed. But after the rotation is equal to 360 ° (0f by the code), the button does not rotate further. I'm at a loss why this is happening.
public GameObject Botton;
private float BottonRotationZ;
public void Rotate()
{
if (Botton.transform.eulerAngles.z == 0f)
{
LeanTween.rotateZ(Botton,90f,0.5f);
}
else if (Botton.transform.eulerAngles.z == 90f)
{
LeanTween.rotateZ(Botton,180f,0.5f);
}
else if (Botton.transform.eulerAngles.z == 180f)
{
LeanTween.rotateZ(Botton,270f,0.5f);
}
else if (Botton.transform.eulerAngles.z == 270f)
{
LeanTween.rotateZ(Botton,0f,0.5f);
}
}