void CreateChallengeDescriptions(Challenge[] challenges) { foreach (Challenge challenge in challenges) { GameObject challengeDescription = Instantiate(challengeDescriptionPrefab) as GameObject; challengeDescription.name = challenge.Name + "Description"; challengeDescription.transform.SetParent(challengeDescriptionParent.transform, false); GameObject titleChild = challengeDescription.transform.FindChild("Title").gameObject; Text titleText = titleChild.GetComponent <Text>(); titleText.text = challenge.Name; colors[0] = Color.white; colors[1] = Color.white; colors[2] = Color.white; if (challenge.Difficulty.Trim() == "Easy") { titleText.color = colors[0]; } if (challenge.Difficulty.Trim() == "Medium") { titleText.color = colors[1]; } if (challenge.Difficulty.Trim() == "Hard") { titleText.color = colors[2]; } GameObject descriptionChild = challengeDescription.transform.FindChild("Description").gameObject; Text descriptionText = descriptionChild.GetComponent <Text>(); GameObject factChild1 = challengeDescription.transform.FindChild("Fact").gameObject; GameObject factChild2 = factChild1.transform.FindChild("scrollBox").gameObject; GameObject factChild = factChild2.transform.FindChild("Text").gameObject; Text factText = factChild.GetComponent <Text>(); String[] strings = challenge.Description.Split(new char[] { '/' }); if (strings.Length > 1) { factText.text = strings[1]; factText.color = new Color(0.01960f, 0.066666f, 0.05882f, 1.0f); } descriptionText.text = strings[0]; GameObject takeSelfieChild = challengeDescription.transform.FindChild("Take Selfie Button").gameObject; TakeSelfieButton buttonId = takeSelfieChild.GetComponent <TakeSelfieButton>(); buttonId.buttonId = challenge.Id; } }
void CreateChallengeDescriptions(Challenge[] challenges) { foreach (Challenge challenge in challenges) { GameObject challengeDescription = Instantiate(challengeDescriptionPrefab) as GameObject; challengeDescription.name = challenge.Name + "Description"; if (challenge.Type.Trim() == "Travel/Tourism") { challengeDescription.transform.SetParent(TravelDescriptionParentObject.transform, false); } if (challenge.Type.Trim() == "Sports") { challengeDescription.transform.SetParent(SportsDescriptionParentObject.transform, false); } if (challenge.Type.Trim() == "Cars") { challengeDescription.transform.SetParent(CarsDescriptionParentObject.transform, false); } if (challenge.Type.Trim() == "Dare to be Digital") { challengeDescription.transform.SetParent(DareToBeDigitalParentObject.transform, false); } if (challenge.Type.Trim() == "People and Places") { challengeDescription.transform.SetParent(PeopleAndPlacesDescriptionParentObject.transform, false); } if (challenge.Type.Trim() == "Miscellaneous") { challengeDescription.transform.SetParent(miscellaneousDescriptionObject.transform, false); } if (challenge.Type.Trim() == "Animals") { challengeDescription.transform.SetParent(AnimalsDescriptionParentObject.transform, false); } if (challenge.Type.Trim() == "Food/Drink") { challengeDescription.transform.SetParent(FoodParentDescriptionObject.transform, false); } if (challenge.Type.Trim() == "Great Outdoors") { challengeDescription.transform.SetParent(GreatOutdoorsDescriptionParentObject.transform, false); } if (challenge.Type.Trim() == "Everyday Life") { challengeDescription.transform.SetParent(EveryDayLifeDescriptionParentObject.transform, false); } if (challenge.Type.Trim() == "Events") { challengeDescription.transform.SetParent(eventsDescriptionObject.transform, false); } GameObject titleChild = challengeDescription.transform.FindChild("Title").gameObject; Text titleText = titleChild.GetComponent <Text>(); titleText.text = challenge.Name; if (challenge.Difficulty.Trim() == "Easy") { titleText.color = colors[0]; } if (challenge.Difficulty.Trim() == "Medium") { titleText.color = colors[1]; } if (challenge.Difficulty.Trim() == "Hard") { titleText.color = colors[2]; } GameObject descriptionChild = challengeDescription.transform.FindChild("Description").gameObject; Text descriptionText = descriptionChild.GetComponent <Text>(); //DEPRICATED // descriptionText.text = challenge.Description; GameObject factChild1 = challengeDescription.transform.FindChild("Fact").gameObject; GameObject factChild2 = factChild1.transform.FindChild("scrollBox").gameObject; GameObject factChild = factChild2.transform.FindChild("Text").gameObject; Text factText = factChild.GetComponent <Text>(); String[] strings = challenge.Description.Split(new char[] { '/' }); if (strings.Length > 1) { factText.text = strings[1]; } Debug.LogError("this should disable: " + factChild1.name); descriptionText.text = strings[0]; GameObject takeSelfieChild = challengeDescription.transform.FindChild("Take Selfie Button").gameObject; TakeSelfieButton buttonId = takeSelfieChild.GetComponent <TakeSelfieButton>(); buttonId.buttonId = challenge.Id; //factChild1.SetActive(false); } }