void OnEnable() { if (!isInitialized) { //find dropdown controll dropdown = GetComponent <Dropdown>(); //load resources groups = Resources.Load(groupsResourcesPath) as BricksGroups; //rebuild dropdown controll dropdown.ClearOptions(); if (groups != null) { List <Dropdown.OptionData> options = new List <Dropdown.OptionData>(); foreach (var group in groups.groups) { var option = new GroupsDropDownOptionData(); var translation = LeanLocalization.GetTranslation(group.translationLabel); option.text = translation != null ? translation.Text : group.translationLabel; option.groupId = group.groupId; options.Add(option); } var sortedOptions = options.OrderBy(x => x.text).ToList(); dropdown.AddOptions(sortedOptions); } isInitialized = true; } }
void OnEnable() { if (isInitialized) { return; } //load resources groups = Resources.Load(groupsResourcesPath) as BricksGroups; //rebuild dropdown controll if (groups != null) { GameObject allButton = scrollRect.content.transform.Find("All").gameObject; if (allButton != null) { foreach (var group in groups.groups) { var newButton = Instantiate(allButton); newButton.transform.SetParent(scrollRect.content); var image = newButton.GetComponentInChildren <Image>(); image.sprite = group.icon; var toolTip = newButton.GetComponentInChildren <ToolTipLocalized>(); toolTip.PhraseName = group.translationLabel; } } if (label != null) { if (groups.groups.Length > 0) { SetLabel("All"); } } else { label.text = ""; } } isInitialized = true; }