コード例 #1
0
    public void FillWeaponDropdown(GameObject unit)
    {
        WepDropdown.ClearItems();
        AttackController uat = unit.GetComponent <AttackController>();

        LocalizedItem[] stringlist = new LocalizedItem[uat.GetWeapons().Count];
        int             listidx    = 0;

        foreach (string key in uat.GetWeapons().Keys)
        {
            int i = key.LastIndexOf("-");
            stringlist[listidx++] = new LocalizedItem(unit.tag.Equals("Marine") ? "Marine_Weapon" : "Weapons", key.Substring(0, i), key.Substring(i));
        }
        WepDropdown.AddItems(stringlist);
        WepDropdown.SelectedIndex = 0;
        if (stringlist.Length > 0)
        {
            FillWeaponFields(stringlist [WepDropdown.SelectedIndex].ToString());
        }
    }