void BuildFullView(CreditsAsset.Category category, Transform viewContainer) { var categoryLabel = Instantiate(CategoryLabelTemplate); SetNameAndText(categoryLabel.gameObject, category.Name); BuildLayout(categoryLabel.gameObject, CreditHeight); categoryLabel.SetParent(viewContainer, false); SetText(categoryLabel.gameObject, category.Name); int segmentCount = 1; foreach (var segment in Segment(category.Contributors.OrderBy(s => s), MaxContributorsPerLine)) { var count = segment.Length; var size = 1 / (float)count; var container = new GameObject(category.Name + " " + segmentCount, typeof(RectTransform)); BuildLayout(container, CreditHeight); container.transform.SetParent(viewContainer, false); for (var i = 0; i < segment.Length; i++) { var optionLabel = Instantiate(OptionLabelTemplate); optionLabel.SetParent(container.transform, false); SetNameAndText(optionLabel.gameObject, segment[i]); FillRect(optionLabel, i * size, size); } segmentCount++; } }
void BuildSingleView(CreditsAsset.Category category, Transform viewContainer) { var container = new GameObject(category.Name, typeof(RectTransform)); BuildLayout(container, CreditHeight); var categoryLabel = Instantiate(CategoryLabelTemplate); categoryLabel.SetParent(container.transform, false); FillRect(categoryLabel, Indent, LabelSize); SetNameAndText(categoryLabel.gameObject, category.Name); foreach (var text in categoryLabel.GetComponentsInChildren <Text>()) { text.alignment = TextAnchor.MiddleLeft; } container.transform.SetParent(viewContainer, false); var optionLabel = Instantiate(OptionLabelTemplate); optionLabel.SetParent(container.transform, false); SetNameAndText(optionLabel.gameObject, category.Contributors[0]); FillRect(optionLabel, LabelSize, (1 - (Indent + LabelSize))); foreach (var text in optionLabel.GetComponentsInChildren <Text>()) { text.alignment = TextAnchor.MiddleRight; } }