setting the anchor points in unity via 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);