Keeping aspect of image

I’m developing a game for mobile and tablet.

I have a background image that has a ratio very similar to tablet’s.

When I’m playing at mobile, I want this background to:

  • stay centered in center of screen
  • keep its original ratio (that means: if the background height stretch to the mobile height, the background sides will be out of the screen)

What should I do with the anchors to get this done?

Can’t you just anchor it to the center of screen?

my anchors look like this:
3262391--251644--Screen Shot 2017-10-22 at 20.27.08.png

and even this way, the image is not stretching up and down when I stretch the game window vertically

You will need to use an Aspect Ratio Fitter component to achieve that. Add it to your image and set it to “Height Controls Width” with the proper ratio.

thanks! but my biggest problem is still the position… I thought it would be simple to kinda attach the anchors of one element in the anchors of another, but it seems it can’t be done

Anchors are always relative to the parent object in the hierarchy. So it’s already the case, I’m not sure what you mean. In any case, you don’t need any particular anchors if you use the aspect ratio fitter. Leave it anchored to the center of your canvas. Don’t you want it to be fullscreen?