hch
6 天以前 ee3196b5a04c15d025d1a9eab825d5d14987758d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using UnityEngine;
using UnityEngine.UI; 
using System;
 
// 一级界面带预制体,底部功能按钮样式
public class OneLevelWin : FunctionsBaseWin
{
    [NonSerialized] GroupButtonEx tabBtn;
    public FuncBtnData[] funcBtnDatas;
    [NonSerialized] Button closeBtn;
    protected override void InitComponent()
    {
        // 创建
        var instance = UIUtility.CreateWidget("OneLevelWin", "BottomTabs");
        instance.transform.SetParentEx(_rectTransform, Vector3.zero, Quaternion.identity, Vector3.one);
        closeBtn = _rectTransform.GetComponent<Button>("BottomTabs/bg/backbtn");
        tabBtn = _rectTransform.GetComponent<GroupButtonEx>("BottomTabs/bg/btns/funcbtn");
        var btnParent = _rectTransform.GetComponent<RectTransform>("BottomTabs/bg/btns");
 
 
        tabButtons = new GroupButtonEx[funcBtnDatas.Length];
        for (int i = 0; i < tabButtons.Length; i++)
        {
            GameObject go = Instantiate(tabBtn.gameObject, btnParent);
            var data = funcBtnDatas[i];
            tabButtons[i] = go.GetComponent<GroupButtonEx>();
            tabButtons[i].selectIcon.SetSprite(data.iconName);
            tabButtons[i].selectIcon.SetNativeSize();
            tabButtons[i].title.text = Language.Get(data.name);
            tabButtons[i].redpoint.redpointId = data.redpointID;
            tabButtons[i].SetActive(true);
        }
        base.InitComponent();
 
        closeBtn.AddListener(CloseWindow);
    }
 
    protected override void OpenSubUIByTabIndex()
    {
    }
 
 
}
 
[Serializable]
public struct FuncBtnData
{
    public int redpointID;
    public string name;
    public string iconName; //默认显示的图标(选中)
}