unity rect transform set reference point in code code example
Example: setting the anchor presets unity
newrect.anchorMin = new Vector2(0.5f, 0);
newrect.anchorMax = new Vector2(0.5f, 0);
newrect.pivot = new Vector2(0, 0);
newrect.anchorMin = new Vector2(0.5f, 0);
newrect.anchorMax = new Vector2(0.5f, 0);
newrect.pivot = new Vector2(0, 0);