Skip to main content

Cannot set transform.position of a UI Image component using Image.transform.position it just stays as zero

This occurs do to this behaviour currently being unsupported in the Luna engine.

Possible solution:

  • Try to use Image.transform.localPosition instead as this can be set. If you are setting the UI Image position from world space position using Camera.main.WorldToScreenPoint(), you may need to offset the final UI Image pixel position by doing the following:
pixelPositionFromWorldSpacePosition.x -= Screen.width / 2;

pixelPositionFromWorldSpacePosition.y -= Screen.height / 2;

Image.gameObject.transform.localPosition = pixelPositionFromWorldSpacePosition;