private float _rotation;
private Quaternion _originalRotation;
// set public to pass child reference in Unity Editor
public Canvas UIrotation;
// Start is called before the first frame update
void Start()
{
// save child rotation values
_originalRotation = UIrotation.transform.rotation;
_rotation = transform.rotation.y;
}
private void OnMouseOver()
{
// rotation of parent
if (Input.GetKeyDown(KeyCode.Space))
{
// parent rotate
transform.Rotate(new Vector3(0, _rotation - 90, 0));
// child rotate back to original without the need of update func
UIrotation.transform.rotation = _originalRotation;
}
}