Search Unity

How to adjust instantiated prefab sizes for different screen sizes?

Discussion in 'UGUI & TextMesh Pro' started by zyonneo, Mar 7, 2019.

  1. zyonneo

    zyonneo

    Joined:
    Apr 13, 2018
    Posts:
    386
    I created a prefab containing a rawimage,text to show name and text show price.I get the details and images from API and instantiate prefabs and apply the info from API.How to adjust image size and text according to different screen sizes.The problem is that the spaces between each cells don’t look equal.Below are the screenshots of image and text in each cell for different screen sizes.I have attached the images with different inspector settings of canvas, cell content size and prefab settings.Should I use script to control the sizes according to screens but that would be difficult.

    Canvas settings -Scale with screen size
    Match width and height
    Reference resolution given as Iphone 6 -750 x 1334

    Two screen difference shown below.How to give equal screen spaces at the sides?


    Prefab contains rawimg,and two texts.
    Prefab-Rawimg Inspector settings given below


    Cell Content Inspector settings


    Canvas Inspector settings given below
     
    Last edited: Mar 7, 2019