| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine.UI; |
| | | using UnityEngine.Events; |
| | | |
| | | namespace Snxxz.UI |
| | | { |
| | |
| | | public class FunctionButtonGroup : MonoBehaviour |
| | | { |
| | | [SerializeField] ScrollRect m_ScrollRect; |
| | | [SerializeField] RectTransform m_Container; |
| | | |
| | | public int unLockedCount { |
| | | get { |
| | |
| | | orders.Add(button.order); |
| | | orders.Sort(OrderCompare); |
| | | } |
| | | |
| | | if (m_ScrollRect != null) |
| | | { |
| | | m_ScrollRect.horizontal = functionButtons.Count > 5; |
| | | } |
| | | } |
| | | |
| | | public void UnRegister(FunctionButton button) |
| | |
| | | orders.Sort(OrderCompare); |
| | | } |
| | | |
| | | if (m_ScrollRect != null) |
| | | { |
| | | m_ScrollRect.horizontal = functionButtons.Count > 5; |
| | | } |
| | | } |
| | | |
| | | public void NotifyToggleOn(FunctionButton button) |
| | |
| | | { |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |