效果圖
GUI部分代碼展示
private Vector2 scrollPos=new Vector2 (0,0);
private bool IsAllOperation = false;
private void OnGUI()
{
GUILayout.BeginHorizontal("HelpBox");
textStyle.fontSize=17;
GUILayout.Label("選擇需要導入到客戶端工程的關卡", textStyle,GUILayout.Width(300));
GUILayout.FlexibleSpace();
GUILayout.FlexibleSpace();
GUILayout.FlexibleSpace();
if (GUILayout.Button("確定導出", GUILayout.Width(100)))
{
foreach(var child in mapDic)
{
if(child.Value)
{
Copy(child.Key);
}
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal("PopupCurveSwatchBackground");
GUILayout.Label("關卡名稱", textStyle, GUILayout.Width(200));
GUILayout.Label("選擇", textStyle, GUILayout.Width(100));
bool tempIsAll = IsAllOperation;
tempIsAll = GUILayout.Toggle(tempIsAll, "全選",GUILayout.Width(100));
if(tempIsAll!=IsAllOperation)
{
IsAllOperation = tempIsAll;
foreach(var child in all_map.Split(':'))
{
if (mapDic.ContainsKey(child))
{
mapDic[child] = IsAllOperation;
}
}
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
scrollPos = GUILayout.BeginScrollView(scrollPos);
textStyle.fontSize = 10;
foreach (var map in all_map.Split(':'))
{
if(mapDic.ContainsKey(map))
{
GUILayout.Space(5);
GUILayout.BeginHorizontal("PopupCurveSwatchBackground");
GUILayout.Label(" "+map, textStyle, GUILayout.Width(200));
bool isOperation = mapDic[map];
isOperation = GUILayout.Toggle(isOperation,"",GUILayout.Width(200));
mapDic[map] = isOperation;
GUILayout.EndHorizontal();
}
}
GUILayout.EndScrollView();
}