少年修仙传客户端代码仓库
client_Wu Xijin
2019-04-28 3b50d06d004ecc31df7ecaa57927fa35c1ea608e
UI/Common/FunctionButtonGroup.cs
@@ -6,6 +6,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine.Events;
namespace Snxxz.UI
{
@@ -13,6 +14,7 @@
    public class FunctionButtonGroup : MonoBehaviour
    {
        [SerializeField] ScrollRect m_ScrollRect;
        [SerializeField] RectTransform m_Container;
        public int unLockedCount {
            get {
@@ -41,6 +43,11 @@
                orders.Add(button.order);
                orders.Sort(OrderCompare);
            }
            if (m_ScrollRect != null)
            {
                m_ScrollRect.horizontal = functionButtons.Count > 5;
            }
        }
        public void UnRegister(FunctionButton button)
@@ -56,6 +63,10 @@
                orders.Sort(OrderCompare);
            }
            if (m_ScrollRect != null)
            {
                m_ScrollRect.horizontal = functionButtons.Count > 5;
            }
        }
        public void NotifyToggleOn(FunctionButton button)
@@ -172,6 +183,33 @@
        {
            return a < b ? -1 : 1;
        }
        public FunctionButton AddFunction(int order, int functionId, string title, int redpointId)
        {
            if (m_Container == null)
            {
                return null;
            }
            var instance = UIUtility.CreateWidget("FunctionButton", string.Concat("Function_", order));
            var functionButton = instance.GetComponent<FunctionButton>();
            functionButton.functionId = functionId;
            functionButton.order = order;
            functionButton.title.text = title;
            functionButton.group = this;
            functionButtons[order] = functionButton;
            return functionButton;
        }
        public void SetFunctionListener(int order, UnityAction callBack)
        {
            if (functionButtons.ContainsKey(order))
            {
                functionButtons[order].SetListener(callBack);
            }
        }
    }
}