コード例 #1
0
        private void RefreshValues()
        {
            dropdown.onValueChanged.RemoveListener(OnDropdownValueChanged);
            dropdown.ClearOptions();
            sfxIdValues.Clear();

            List <TMPro.TMP_Dropdown.OptionData> data = new List <TMPro.TMP_Dropdown.OptionData>();

            data.Add(new TMPro.TMP_Dropdown.OptionData("(none)"));
            sfxIdValues.Add(null);

            foreach (SoundEffectListing listing in sfxSystem.ListAll())
            {
                data.Add(new TMPro.TMP_Dropdown.OptionData(listing.name));
                sfxIdValues.Add(listing.id);
            }

            dropdown.options = data;
            string pfxId = (string)editor.data;
            int    index = sfxIdValues.IndexOf(pfxId);

            if (index < 0)
            {
                dropdown.value = 0;
            }
            dropdown.onValueChanged.AddListener(OnDropdownValueChanged);
        }
コード例 #2
0
    private void RepopulateList()
    {
        foreach (ScrollingListItemUI entry in entries.Values)
        {
            Destroy(entry.gameObject);
        }
        entries.Clear();

        List <SoundEffectListing> list = soundEffectSystem.ListAll();

        foreach (SoundEffectListing listing in list)
        {
            ScrollingListItemUI entry = Instantiate(ui.soundPickerItemTemplate, ui.soundPickerList.transform);
            entry.gameObject.SetActive(true);
            entry.textField.text = listing.name;
            // entry.Set(listing);
            entry.button.onClick.AddListener(() => OnSoundEffectClicked(listing.id));
            string name = listing.name;
            entries.Add(listing.id, entry);
        }
    }
コード例 #3
0
    public void Refresh()
    {
        List <SoundEffectListing> soundEffectListings = soundEffectSystem.ListAll();
        string selectedId      = selectedListItem?.name;
        bool   hasSelectedItem = false;

        ui.soundsList.noneText.gameObject.SetActive(soundEffectListings.Count == 0);

        // Reuse as much of the list as possible to cut down on creating/destroying new objects:
        for (int i = 0; i < Mathf.Max(soundEffectListings.Count, listItems.Count); i++)
        {
            if (i < listItems.Count && i < soundEffectListings.Count)
            {
                // Reuse this list item.
                UpdateSoundListItem(listItems[i], soundEffectListings[i]);
            }
            else if (i < soundEffectListings.Count)
            {
                // Create a new list item.
                UpdateSoundListItem(CreateNewSoundListItem(), soundEffectListings[i]);
            }
            else
            {
                // Delete this list item.
                GameObject.Destroy(listItems[i].gameObject);
                listItems.RemoveAt(i);
            }
            if (i < soundEffectListings.Count && soundEffectListings[i].id == selectedId)
            {
                SetSelectedSound(listItems[i]);
                hasSelectedItem = true;
            }
        }
        if (!hasSelectedItem)
        {
            SetSelectedSound(null);
        }
    }