Ejemplo n.º 1
0
    private void UpdateMaterialUI(bool unused)
    {
        foreach (var element in layoutElements)
        {
            Destroy(element);
        }

        layoutElements.Clear();

        foreach (var material in upgrade.UpgradeMaterials)
        {
            var matByName = layoutElements.SingleOrDefault(x => x.name == (material.Mat as ScriptableObject).name);
            if (matByName == null)
            {
                var obj = Instantiate(pfMaterialElement, tMaterialElement);
                obj.name = (material.Mat as ScriptableObject).name;
                obj.GetComponent <SetupClickableImage>().Setup(material.Mat.Sprite, material.quantity, () => upgrade.DeselectMaterial(material.Mat));
                layoutElements.Add(obj);
            }
            else
            {
                matByName.GetComponent <SetupClickableImage>().AdjustCount(material.quantity);
            }
        }
    }