I am creating a new GameObject and set it as a child of another UI gameobject:
child = new GameObject("Child", typeof(RectTransform));
child.transform.SetParent(transform);
The UI gameobject I set as the parent:
It does not have rotation. The canvas, which has a rotation (automatically matches the camera rotation):
and the child object resulting from the code snippet:
As you can see somehow the child object gets the negative rotation of the canvas. However I can not edit the rotation in code.
child.transform.rotation = Quaternion.Euler(Vector3.zero);
child.transform.rotation = Quaternion.identity;
i tried this with both the Transform.rotation as well as the RectTransform.rotation and it will always reset back to the default rotation on play.