public void Display(QuizContent _content) { var content = _content as MultipleChoice; PrefabList.CacheInstances( prefab: OptionPrefab, parent: MultipleChoiceOptionContainer, amountWanted: content.QuizOptions.Count, cache: multipleChoiceObjects ); for (int i = 0; i < content.QuizOptions.Count; i++) { multipleChoiceObjects[i].GetComponentInChildren <Text>().text = content.QuizOptions[i].optionText; } }
/// <summary>Display the given content in the UI</summary> public void Display(UiContent content) { TitleObject.text = content.Title.ToUpper(); PrefabList.CacheInstances(DescriptionPrefab, transform, content.Description.Count, descriptionObjects); for (int i = 0; i < content.Description.Count; i++) { descriptionObjects[i].text = content.Description[i]; } PrefabList.CacheInstances(ImagePrefab, transform, content.Images.Count, imageObjects); for (int i = 0; i < content.Images.Count; i++) { var img = imageObjects[i].GetComponentInChildren <Image>(); var fitter = imageObjects[i].GetComponentInChildren <AspectRatioFitter>(); var sprite = content.Images[i]; if (sprite) { fitter.aspectRatio = sprite.rect.size.x / sprite.rect.size.y; img.sprite = sprite; } } }