From 3b50d06d004ecc31df7ecaa57927fa35c1ea608e Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期日, 28 四月 2019 16:59:23 +0800
Subject: [PATCH] 3335 修改界面功能框架。
---
UI/Common/FunctionButtonGroup.cs | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/UI/Common/FunctionButtonGroup.cs b/UI/Common/FunctionButtonGroup.cs
index af06211..73ac4f1 100644
--- a/UI/Common/FunctionButtonGroup.cs
+++ b/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);
+ }
+ }
+
}
}
--
Gitblit v1.8.0