- Home /
 
               Question by 
               H3ll0VR · Jan 23, 2019 at 11:36 AM · 
                uiscreen resolutionscreen sizescreen.widthscreen.height  
              
 
              Screen.width/Screen.height not working with multiple resolutions
I've been using Screen.width/Screen.height to scale UI elements (in this case a GridLayoutGroup) for a while and all of a sudden it doesn't seem to be setting the correct sizes. This is driving me insane. Code setting the sizes for different iPhone ratios/resolutions below. I tried to attach screenshots but they're too large.
 GridLayoutGroup grid = GetComponent<GridLayoutGroup>();
 float xRatio = 0.4f;
 //previously did this but it was too big?
  //float x = (Screen.width - grid.spacing.x - grid.padding.left - grid.padding.right) / 2;
 float x = Screen.width * xRatio;
 grid.cellSize = new Vector2(x, x);
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                