title: Unity3D Canvas scaleFactor not working correctly
body: <p>I have been working on the UI of a game I am making with in this part of the UI it generates a line via script. (see below)</p>
  
  <pre><code>//Total Width Line
  float lineTotalWidth = (gameObject.GetComponent&lt;RectTransform&gt;().rect.width * Canvas.scaleFactor);
  
  //Start Postion Line
  float currentX = 0 - (transform.GetComponent&lt;VerticalLayoutGroup&gt;().padding.left * Canvas.scaleFactor);
  float currentY = 0;
  </code></pre>
  
  <p>I calculate the line width with the with of the object * canvas.scaleFactor and this is working perfectly (see image)</p>
  
  <p><a href="https://i.stack.imgur.com/lDnJt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lDnJt.png" alt="enter image description here"></a></p>
  
  <p>But after I change the resolution the line doesn't calculate the width correctly anymore. I know this has something to do with the canvas.scaleFactor but I cant figure out what.</p>
  
  <p><a href="https://i.stack.imgur.com/mfIPr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mfIPr.png" alt="enter image description here"></a></p>
  
  <p>Does anybody know how I can make sure the line updates with the screen resolution correctly.
  Thank you in advance.</p>