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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
| using UnityEngine;
| using UnityEngine.UI;
| /**
| 这是新的二级界面加载器
| */
| namespace vnxbqy.UI
| {
|
| public enum FrameSize
| {
| Free,
| XLarge,
| Large,
| Medium,
| Small,
| }
|
| [ExecuteAlways]
| public class SecondFrameLoader2 : UIPrefabLoader
| {
| [SerializeField] public FrameSize frameSize;
|
| [SerializeField] public Vector2 size;
|
| public string m_TitleKey;
|
| public override string prefabName { get { return "SecondFrame"; } }
|
| public override void Create()
| {
| base.Create();
| UpdateSize();
| InitUI();
| }
|
| private void Update()
| {
| if (Application.isPlaying)
| return;
| UpdateSize();
| }
|
| public void InitUI()
| {
| var button = this.GetComponentInChildren<ButtonEx>();
| var window = this.GetComponentInParent<Window>();
| button.AddListener(() =>//关闭按钮
| {
| DebugEx.Log("关闭窗口");
| window.Close();
| });
| if (!string.IsNullOrEmpty(m_TitleKey))
| {
| var text = this.GetComponentInChildren<Text>();
| if (text != null)
| {
| if (Application.isPlaying)
| text.text = Language.Get(m_TitleKey);
| else
| text.text = "当前标题";
| }
| }
| }
|
| public void UpdateSize()
| {
| if (instance == null)
| return;
| switch (frameSize)
| {
| case FrameSize.XLarge:
| {
| SetSize(1000, 650);
| break;
| }
| case FrameSize.Large:
| {
| SetSize(800, 650);
| break;
| }
| case FrameSize.Medium:
| {
| SetSize(650, 650);
| break;
| }
| case FrameSize.Small:
| {
| SetSize(550, 650);
| break;
| }
| case FrameSize.Free:
| {
| SetSize(size.x, size.y);
| break;
| }
| }
| }
|
| private void SetSize(float width, float height)
| {
| if (instance == null)
| return;
| (instance.transform as RectTransform).sizeDelta = new Vector2(width, height);
| }
|
| }
|
| }
|
|