Example #1
0
    void SpawnButton(Item i, Fighter f)
    {
        GameObject go  = Instantiate(itemButtonPrefab, itemList.transform);
        ItemButton btn = go.GetComponent <ItemButton>();

        go.GetComponent <UIHighlight>().OnSelectAction += () => { hovered = btn.GetItem(); };
        go.GetComponent <Button>().onClick.AddListener(() => { OpenActionMenu(); });

        if (i.IsUseable(f))
        {
            btn.label.color = Color.white;
        }
        else
        {
            btn.label.color = Color.gray;
        }

        btn.SetItem(i);
    }