Skip to content

Commit 1e22135

Browse files
author
zouhangte
committed
upload files
1 parent 09ddeef commit 1e22135

File tree

582 files changed

+34461
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

582 files changed

+34461
-0
lines changed

Common/Controllers.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Common/Controllers/ListItemCreater.cs

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#region statement
2+
/*************************************************************************************
3+
* 作 者: zouhunter
4+
* 时 间: 2018-02-06 11:27:06
5+
* 说 明:
6+
1.调用了内部的对象池
7+
2.只创建少量的列表对象时使用
8+
3.对于会发生变化的对象,在Revert中重置
9+
4.按父级是否有Recttransform判断是否是ui
10+
* ************************************************************************************/
11+
#endregion
12+
using System;
13+
using UnityEngine;
14+
using UnityEngine.UI;
15+
using UnityEngine.Events;
16+
using System.Collections;
17+
using System.Collections.Generic;
18+
using UnityEngine.Internal;
19+
20+
namespace BridgeUI.Common
21+
{
22+
public interface IListItem {
23+
void Revert();
24+
}
25+
/// <summary>
26+
/// 这是一个列表创建器(用于快速创建一组对象)
27+
/// 建议数量 < 100
28+
/// </summary>
29+
/// <typeparam name="T"></typeparam>
30+
public class ListItemCreater<T> where T : MonoBehaviour, IListItem
31+
{
32+
public List<T> CreatedItems { get { return createdItems; } }
33+
Transform parent { get; set; }
34+
T pfb { get; set; }
35+
private GameObjectPool objectPool;
36+
private bool isword;
37+
List<T> createdItems = new List<T>();
38+
public ListItemCreater(Transform parent, T pfb)
39+
{
40+
this.parent = parent;
41+
this.pfb = pfb;
42+
pfb.gameObject.SetActive(false);
43+
objectPool = UIFacade.PanelPool;
44+
isword = !parent.GetComponent<RectTransform>();
45+
}
46+
47+
public T[] CreateItems(int length)
48+
{
49+
ClearOldItems();
50+
if (length <= 0) return new T[0];
51+
52+
GameObject go;
53+
for (int i = 0; i < length; i++)
54+
{
55+
go = objectPool.GetPoolObject(pfb.gameObject, parent, isword);
56+
T scr = go.GetComponent<T>();
57+
createdItems.Add(scr);
58+
}
59+
return createdItems.ToArray();
60+
}
61+
62+
public T AddItem()
63+
{
64+
if (pfb == null) return null;
65+
GameObject go;
66+
go = objectPool.GetPoolObject(pfb.gameObject, parent, isword);
67+
T scr = go.GetComponent<T>();
68+
createdItems.Add(scr);
69+
return scr;
70+
}
71+
72+
public void RemoveItem(T item)
73+
{
74+
createdItems.Remove(item);
75+
objectPool.SavePoolObject(item.gameObject, isword);
76+
}
77+
78+
public void ClearOldItems()
79+
{
80+
foreach (var item in createdItems)
81+
{
82+
objectPool.SavePoolObject(item.gameObject, isword);
83+
}
84+
85+
createdItems.Clear();
86+
}
87+
}
88+
89+
}

Common/Controllers/ListItemCreater.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#region statement
2+
/*************************************************************************************
3+
* 作 者: zouhunter
4+
* 时 间: 2018-02-06 11:27:06
5+
* 说 明: 1.这是一个简单类型的Toggle列表生成器
6+
2.传入字符串数组
7+
3.返回id或者对应的字符串
8+
* ************************************************************************************/
9+
#endregion
10+
using UnityEngine;
11+
using UnityEngine.UI;
12+
using UnityEngine.Events;
13+
using System.Collections;
14+
using System.Collections.Generic;
15+
using System;
16+
17+
namespace BridgeUI.Common
18+
{
19+
[System.Serializable]
20+
public class ToggleListSelector
21+
{
22+
[SerializeField]
23+
private Transform m_parent;
24+
[SerializeField]
25+
private GameObject m_prefab;
26+
[SerializeField]
27+
private Button m_Select;
28+
private string selected;
29+
private UnityAction<string> onChoise;
30+
private Dictionary<string, Toggle> createdDic;
31+
private ToggleGroup group;
32+
private bool quick;
33+
private string[] options;
34+
public bool AnyToggleOn { get { return group.AnyTogglesOn(); } }
35+
private bool stopEvent;
36+
private GameObjectPool gameObjectPool;
37+
private bool inited;
38+
/// <summary>
39+
/// 调用其他方法时,先进行初始化
40+
/// </summary>
41+
public void Init()
42+
{
43+
gameObjectPool = UIFacade.PanelPool;
44+
if (m_Select) m_Select.onClick.AddListener(TrySelectItem);
45+
group = m_parent.GetComponentInChildren<ToggleGroup>();
46+
if (group == null)
47+
group = m_parent.gameObject.AddComponent<ToggleGroup>();
48+
inited = true;
49+
}
50+
51+
public void OpenSelect(string[] selectables, UnityAction<string> onChoise, bool quick = false)
52+
{
53+
if(JudgeInit())
54+
{
55+
this.options = selectables;
56+
this.quick = quick;
57+
this.onChoise = onChoise;
58+
CreateUIList(selectables);
59+
}
60+
}
61+
62+
63+
public void OpenSelect(string[] selectables, UnityAction<int> onChoise, bool quick = false)
64+
{
65+
if (JudgeInit())
66+
{
67+
this.options = selectables;
68+
this.quick = quick;
69+
this.onChoise = (x) =>
70+
{
71+
if (onChoise != null)
72+
{
73+
var id = System.Array.IndexOf(options, selected);
74+
onChoise.Invoke(id);
75+
}
76+
};
77+
CreateUIList(selectables);
78+
}
79+
}
80+
81+
public void SetActiveItem(string key)
82+
{
83+
if (JudgeInit())
84+
{
85+
stopEvent = true;
86+
87+
if (createdDic.ContainsKey(key))
88+
{
89+
createdDic[key].isOn = true;
90+
}
91+
stopEvent = false;
92+
}
93+
}
94+
private bool JudgeInit()
95+
{
96+
Debug.Assert(inited, this + ":please init first!!!");
97+
return inited;
98+
}
99+
100+
void TrySelectItem()
101+
{
102+
if (this.onChoise != null)
103+
{
104+
this.onChoise.Invoke(selected);
105+
}
106+
107+
}
108+
void OnSelect(string type)
109+
{
110+
selected = type;
111+
if (quick)
112+
{
113+
TrySelectItem();
114+
}
115+
}
116+
void CreateUIList(string[] selectables)
117+
{
118+
if (createdDic == null)
119+
{
120+
createdDic = new Dictionary<string, Toggle>();
121+
}
122+
else
123+
{
124+
foreach (var item in createdDic)
125+
{
126+
var toggle = item.Value;
127+
toggle.onValueChanged.RemoveAllListeners();
128+
gameObjectPool.SavePoolObject(item.Value.gameObject, false);
129+
}
130+
createdDic.Clear();
131+
}
132+
133+
for (int i = 0; i < selectables.Length; i++)
134+
{
135+
//Debug.Log(SceneMain.Current);
136+
var item = gameObjectPool.GetPoolObject(m_prefab.gameObject, m_parent, false);
137+
var type = selectables[i];
138+
item.GetComponentInChildren<Text>().text = type;
139+
var toggle = item.GetComponentInChildren<Toggle>();
140+
Debug.Assert(toggle, "预制体或子物体上没有toggle组件");
141+
toggle.group = group;
142+
toggle.onValueChanged.AddListener((x) => { if (!stopEvent) OnSelect(type); });
143+
createdDic.Add(type, toggle);
144+
}
145+
}
146+
}
147+
}

Common/Controllers/ToggleListSelector.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Common/SinglePanels.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Common/SinglePanels/ButtonOpenPanel.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#region statement
2+
/*************************************************************************************
3+
* 作 者: zouhunter
4+
* 时 间: 2018-02-06 01:13:36
5+
* 说 明: 1.绑定目标面板名和本地button
6+
* ************************************************************************************/
7+
#endregion
8+
using UnityEngine;
9+
using UnityEngine.UI;
10+
using UnityEngine.Events;
11+
using System.Collections;
12+
using System.Collections.Generic;
13+
14+
namespace BridgeUI.Common
15+
{
16+
/// <summary>
17+
///利用按扭打开其他面板
18+
/// </summary>
19+
public sealed class ButtonOpenPanel : SinglePanel
20+
{
21+
[System.Serializable]
22+
public class Holder
23+
{
24+
public string panelName;
25+
public Button button;
26+
}
27+
public List<Holder> holders = new List<Holder>();
28+
29+
protected override void Awake()
30+
{
31+
base.Awake();
32+
foreach (var item in holders)
33+
{
34+
if (item.button != null && !string.IsNullOrEmpty(item.panelName))
35+
{
36+
item.button.onClick.AddListener(() => { this.Open(item.panelName); });
37+
}
38+
}
39+
}
40+
}
41+
}

Common/SinglePanels/ButtonOpenPanel/ButtonOpenPanel.cs.meta

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Common/SinglePanels/ButtonOpenPanel/Editor.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)