Exemplo n.º 1
0
    public void AddUnitButton(string name)
    {
        UnitToolbarItem button = Instantiate(buttonPrefab, listTransform);

        buttons.Add(button);
        button.unitName = name;
        Debug.Log("Setting Unit sprite -> buttons count: " + buttons.Count + "\t unit sprites count: " + unitSprites.Count + "\t result: " + buttons.Count % unitSprites.Count);
        button.unitImage.sprite = unitSprites[buttons.Count % unitSprites.Count];
        button.SetKeyCode(buttons.Count - 1);
        button.characterIndex = buttons.Count - 1;
    }
Exemplo n.º 2
0
    public void RemoveUnitButton(string name)
    {
        UnitToolbarItem unitToDelete = buttons.Find(x => x.unitName == name);

        if (unitToDelete != null)
        {
            buttons.Remove(unitToDelete);
            Destroy(unitToDelete.gameObject);
        }
        else
        {
            Debug.LogError("Failed to find unit toolbar button with name: " + name);
        }
    }