Exemplo n.º 1
0
    private void PrepareTypeButtons()
    {
        if (TypeButtons.Count > 0)
        {
            foreach (var item in TypeButtons)
            {
                Destroy(item.gameObject);
            }
            TypeButtons = new List <ModButton>();
        }
        GameObject buttonPrefab = Resources.Load <GameObject>("ModSystem/UI/Button");

        foreach (var item in target.GetCompatiblePartTypes(SelectedCat))
        {
            var gm = Instantiate(buttonPrefab, TypeBar.transform);

            var btn = gm.GetComponent <Button>();
            btn.onClick.AddListener(delegate { ChangeType(item); });

            var modbtn = gm.GetComponent <ModButton>();
            modbtn.TranslationName = $"TYPE_{item}";
            modbtn.Name            = item;

            TypeButtons.Add(modbtn);
        }
        try
        {
            ChangeType(TypeButtons[0].Name);
        }
        catch { }
    }