hch
12 小时以前 c6ea64fb4e4755c4290bf5228d8cd463bc81c21f
Main/Component/UI/Common/CountControler.cs
@@ -15,6 +15,7 @@
    int count;  //当前数量
    int maxCount;   //最大数量
    string format;
    Action<int> OnChangeEvent;
    Func<int, bool> CanAddEvent;
@@ -60,13 +61,15 @@
    }
    public void Init(Action<int> _OnChangeEvent, int _maxCount, int _count = 1, Func<int, bool> _CanAddEvent = null, Func<int, bool> _CanDecEvent = null)
    public void Init(Action<int> _OnChangeEvent, int _maxCount, int _count = 1,
    Func<int, bool> _CanAddEvent = null, Func<int, bool> _CanDecEvent = null, string _format="{0}/{1}")
    {
        count = _count;
        maxCount = _maxCount;
        OnChangeEvent = _OnChangeEvent;
        CanAddEvent = _CanAddEvent;
        CanDecEvent = _CanDecEvent;
        format = _format;
        Refresh();
@@ -99,7 +102,7 @@
            decBtn.SetColorful(null, true);
        }
        countText.text = count + "/" + maxCount;
        countText.text = string.Format(format, count, maxCount);
        OnChangeEvent?.Invoke(count);
    }