title: Convert a Transform to a RectTransform
body: <p>In my Unity project, I am creating objects dynamically through scripts.</p>
  
  <pre><code>var btnExit = new GameObject("Player " + ID + "'s Exit Button");
  btnExit.transform.SetParent(UI.transform);
  </code></pre>
  
  <p>I need to set the anchors and pivot of the object. I should be able to do that using its RectTransform component, as I do it when I create objects in the scene editor.</p>
  
  <pre><code>myRectTransform.anchorMin = new Vector2(1, 0);
  myRectTransform.anchorMax = new Vector2(0, 1);
  myRectTransform.pivot = new Vector2(0.5f, 0.5f);
  </code></pre>
  
  <p>But the object's transform component is not a RectTransform, just the normal Transform. So I can't cast it to use those properties I need.</p>
  
  <pre><code>RectTransform myRectTransform = (RectTransform)btnExit.transform;
  </code></pre>
  
  <p>So how can I properly use the power of the RectTransform class on an object that I initialise through scripts instead of in the scene editor?</p>