Exemplo n.º 1
0
    // Update all filter data to show on conv operation canvas
    private void UpdateFilters()
    {
        // Load sprites from conv1 or conv2 filters depending on layer name
        Sprite[] filterSprites = spriteLoader.GetFilterSprites(selectedLayer.GetLayerName());

        // number of filter/fms
        // length of array with filters = number of filters/fms
        int filterLength = filterSprites.Length;

        if (filterLength < 2)
        {
            Debug.Log("CanvasController - UpdateFilters(): No filter sprites loaded");
            return;
        }

        // Set text for number of filters on canvas
        filterNum.text = filterLength.ToString() + " Filter";

        // Add loaded sprites from resources to buttons on canvas
        if (filterBtns.Length > 0)
        {
            for (int i = 0; i < filterLength; i++)
            {
                filterBtns[i].image.sprite = filterSprites[i];
                filterBtns[i].gameObject.SetActive(true);
            }

            // If there are more Buttons than sprites set remaining buttons to inactive
            if (filterBtns.Length > filterLength)
            {
                for (int i = filterLength; i < filterBtns.Length; i++)
                {
                    filterBtns[i].gameObject.SetActive(false);
                }
            }
        }
    }