void HandleOnItemLoadedHandler(ListItemBase item) // reference to the loaded list item { if (item == (ListItemCountry)_selectedItem) { _selectedItem.Select(_selectedIndex == _selectedItem.Index); } ListItemCountry countryItem = (ListItemCountry)item; // cast to your own ListItem countryItem.SetCode(_countries[item.Index].Key); countryItem.SetLabel(_countries[item.Index].Value.Name); }
void HandleOnItemSelectedHandler(ListItemBase item) // reference to the selected list item { if (_selectedItem != null) { _selectedItem.Select(false); } _selectedItem = (ListItemCountry)item; _selectedItem.Select(true); _selectedIndex = _selectedItem.Index; #if UNITY_EDITOR || DEVELOPMENT_BUILD Debug.Log("Selected Country | " + _countries[item.Index].Value.Name); #endif }
void HandleOnItemSelectedHandler(ListItemBase item) // reference to the selected list item { if (_selectedItem != null) { _selectedItem.Select(false); } _selectedItem = (ListItemCountry)item; _selectedItem.Select(true); _selectedIndex = _selectedItem.Index; #if UNITY_EDITOR || DEVELOPMENT_BUILD Debug.Log("Selected Country | " + _countries[item.Index].Value.Name); #endif GameObject.Find("Food_Image").GetComponent <CanvasGroup> ().alpha = 1; Image i = GameObject.Find("Food_Image").GetComponent <Image> (); i.sprite = Resources.Load <Sprite> ("flags/" + _countries[item.Index].Value.Name); Text t = GameObject.Find("Food_Title").GetComponent <Text> (); t.text = _countries [item.Index].Value.Name; GameObject.Find("Food_Description").GetComponent <Text>().text = _countries[item.Index].Value.CodeAlpha3; GameObject.Find("Food_Group").GetComponent <Text>().text = _countries[item.Index].Value.Foodgroup; Opening_Values.selectedfood = _countries [item.Index].Value.Name; Opening_Values.selectedfoodfd = _countries [item.Index].Value.CodeAlpha3; Opening_Values.selectedfoodfoodgroup = _countries [item.Index].Value.Foodgroup; AudioSource audio = gameObject.AddComponent <AudioSource>(); allAudioSources = FindObjectsOfType(typeof(AudioSource)) as AudioSource[]; foreach (AudioSource audioS in allAudioSources) { audioS.Stop(); } audio.PlayOneShot((AudioClip)Resources.Load("audio/" + _countries [item.Index].Value.Name)); }