Beispiel #1
0
 private void Active(Button b)
 {
     foreach (Button button in activeBuffBtns)
     {
         if (b.Equals(button))
         {
             ButtonUtil.Active(button);
         }
         else
         {
             ButtonUtil.Disactive(button);
         }
     }
 }
Beispiel #2
0
    // Start is called before the first frame update
    void Start()
    {
        string m_FileName = "道具.txt";

        string[] strs;
        string   path = Application.persistentDataPath + "/" + m_FileName;

        if (!File.Exists(path))
        {
            strs = new string[] { "1", "1", "1", "1" };
            File.Create(path).Dispose();
            File.WriteAllLines(path, strs);
        }
        else
        {
            strs = File.ReadAllLines(path);
        }
        for (int i = 0; i < 4; i++)
        {
            buffBtns[i] = transform.GetChild(i).gameObject.GetComponent <Button>();
            if (strs[i].Equals("0"))
            {
                ButtonUtil.Disactive(buffBtns[i]);
                buffBtns[i].gameObject.transform.Find("Lock").gameObject.SetActive(true);
            }
            else
            {
                activeBuffBtns.Add(buffBtns[i]);
            }
        }
        for (int i = 0; i < activeBuffBtns.Count; i++)
        {
            int index = i;
            activeBuffBtns[i].onClick.AddListener(delegate()
            {
                Active(activeBuffBtns[index]);
            });
        }
    }