How to find an object's rotation in 2D

Hello,

So I have this object in 2D that rotates 90 degrees every time it is clicked. So there are four cases. How can I know the object’s exact rotation? The object’s parent also rotates the same way. EulerAngles and transform.rotation seem to give random numbers.

Any ideas?

Perhaps try using Vector2.SignedAngle in combination with transform.up and Vector2.up. You might need to flip the process with a negative in front of the signed_angle depending on wether you want it clockwise or not.

Vector2 obj_up = (Vector2) transform.up;
float signed_angle = Vector2.SignedAngle(obj_up, Vector2.up);
float angle = signed_angle;
if (angle < 0) {
    angle += 360f;
}

Or you can use transform.eulerAngles which is supposed to give you the rotation in degrees of the object around each axis, in your case you would want to look at the z axis for the rotation, although you mentioned you were having trouble with that one.