Esempio n. 1
0
    private void PopulateGrid()
    {
        ClearGrid();
        string            categoryName = iconCategories[categoryDropdown.value];
        IconPickerIconRow thisRow      = null;

        foreach (string iconName in iconLoader.EnumerateIcons(categoryName))
        {
            if (thisRow == null || thisRow.IsFull())
            {
                // Start a new row.
                thisRow = CreateNewIconRow();
            }
            Image  newImage;
            Button newButton;
            thisRow.AddCell(out newImage, out newButton);
            iconLoader.LoadIconSprite(iconName, (name, sprite) =>
            {
                newImage.sprite = sprite;
                newImage.color  = Color.white;
            });
            newButton.onClick.AddListener(() =>
            {
                HandleIconClicked(iconName);
            });
        }
    }
Esempio n. 2
0
    private IconPickerIconRow CreateNewIconRow()
    {
        GameObject newRow = GameObject.Instantiate(iconRowTemplate);

        newRow.SetActive(true);
        newRow.transform.SetParent(iconRowTemplate.transform.parent, worldPositionStays: false);
        newRow.transform.SetAsLastSibling();
        IconPickerIconRow result = newRow.GetComponent <IconPickerIconRow>();

        Debug.Assert(result != null, "Icon picker row template must have IconPickerIconRow script");
        return(result);
    }