ict.shenzhi/Assets/Scripts/UI/MainScenesUI/MainPanel/Submit.cs

104 lines
3.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using DG.Tweening;
using TMPro;
public class Submit : UIController
{
[SerializeField] Image im;
[SerializeField] Image BG;
[SerializeField] Button btn;
public Dictionary<string,string> strings = new Dictionary<string, string>();
[SerializeField] TextMeshProUGUI text;
[SerializeField] Transform trans;
[SerializeField] int sum1;
[SerializeField] List<da> das = new List<da>();
private void Start()
{
strings.Add("kaljshd","akjshd,ahkjsdh,askjhd,akkjshd,kjahsd");
strings.Add("kaljshd11","akjshd,ahkjsdh,askjhd,akkjshd,kjahsd");
btn.onClick.AddListener(() =>
{
//if (transform.name.Contains("ÔÝ´æ"))
//{
// MainPanel.ins.ZanCunPanel();
//}
switch (transform.name)
{
case "ÔÝ´æPanel(Clone)":
MainMenuPanel.ins.ZanCunPanel();
break;
case "Ìá½»Panel(Clone)":
MainMenuPanel.ins.Submit();
break;
case "ÏÂÔØPanel(Clone)":
MainMenuPanel.ins.XiaZaiPanel();
break;
default:
break;
}
});
if (transform.name.Equals("ÏÂÔØPanel(Clone)"))
{
GengXin();
}
}
private void OnEnable()
{
base.show(im, BG);
}
private void OnDisable()
{
this.hide(im, BG);
}
void GengXin()
{
foreach (var item in strings)
{
TextMeshProUGUI tex =Instantiate(text,trans);
tex.text = item.Key;
var temp = item.Value.Split(',');
tex.name = sum1.ToString();
List<GameObject> tempGame = new List<GameObject>();
for (int i = 0; i < temp.Length; i++)
{
TextMeshProUGUI te = Instantiate(text,trans);
te.text = " " + temp[i];
tempGame.Add(te.gameObject);
Destroy(te.GetComponent<Button>());
}
da da = new da();
da.btn = tex.GetComponent<Button>();
da.items = new List<GameObject>(tempGame);
das.Add(da);
sum1++;
}
foreach (var item in das)
{
item.btn.GetComponent<Button>().onClick.AddListener(() =>
{
for (int i = 0; i < item.items.Count; i++)
{
if (item.items[i].active)
{
item.items[i].gameObject.SetActive(false);
}
else
{
item.items[i].gameObject.SetActive(true);
}
}
});
}
}
}
[Serializable]
public struct da
{
public Button btn;
public List<GameObject> items;
}