- Home /
prefabs inside content area not fitting entire width of 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 some screenshots 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.
unityanswers.jpg
(339.2 kB)
Comment