# Game Object will NOT stretch across entire content area

I'm loading prefabs into a content area using a content size fitter and vertical layout group. I've tried multiple things to get the loaded prefabs to stretch across the entire content size (including the Unity Manual for this issue), but I'm at an impass. I'll post a screenshot below to show what I'm working with:

Here's how I'm loading in the prefabs in case this is where i'm screwing up:

void CreateRaceSelect() {

for (int i = 0; i < races.races.Count; i++) {
raceButton = (GameObject)Instantiate(raceButtonPrefab);
raceText = raceButton.transform.FindChild("Text").GetComponent<Text>();

raceButton.name = i.ToString();
raceButton.transform.SetParent(content.transform);
raceButton.GetComponent<RectTransform>().localPosition = new Vector3(xPos, yPos, 0);
raceText.text = races.races[i].ToString();
yPos -= (int)raceButton.GetComponent<RectTransform>().rect.height;
}
}


I'm sure this is a minor screw up but at this point I have no other ideas.

• I see you have selected "stretch" on one of the Rect transforms. Did you try holding down alt when you did this? The option natively changes the anchor; you need to hold alt (cmd on Mac) to change position, and without doing so, stretching does not seem to have an effect. – Gnemlock Dec 6 '16 at 1:07
• I have the content set to stretch across the entire width of the View Area. Checking the Anchors, the 4 anchor points are distributed to each corner of the view port – Adariel Lzinski Dec 6 '16 at 1:15
• That is not what I asked. When you change the anchor, it does not appear to enforce stretching. You need to hold alt / cmd and change the anchor, to "Also set position". Note that it will show you "stretch" as being selected without this. The fact that the anchors are set in any way means nothing in the context where I have used image/gui stretching. – Gnemlock Dec 6 '16 at 1:32
• Yes I tried that as well. – Adariel Lzinski Dec 6 '16 at 1:33
• Can you clarify what object should stretch where? I don't really get what you're asking here. Also, in a case like this, the file structure is really important, since stretching is a parent-child relationship. – John Hamilton Dec 6 '16 at 6:46