HKMBFZ/Assets/Scripts/Szz_Scripts/UI/181/DataShow.cs

96 lines
2.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class DataShow : MonoBehaviour
{
public TextMeshProUGUI data;
string value;
public TextMeshProUGUI ;
public TextMeshProUGUI ;
public TextMeshProUGUI ;
public TextMeshProUGUI ;
public Transform itemPra;
List<QiXiangData> qiXiangDatas = new List<QiXiangData>();
// Start is called before the first frame update
void Start()
{
//默认清除所有数据
for (int j = 0; j < itemPra.childCount; j++)
{
itemPra.GetChild(j).GetChild(0).GetComponent<TextMeshProUGUI>().text = "";
itemPra.GetChild(j).GetChild(1).GetComponent<TextMeshProUGUI>().text = "";
itemPra.GetChild(j).GetChild(2).GetComponent<TextMeshProUGUI>().text = "";
}
value = data.text;
//解析数据并填充
string[] result = value.Split('-');
.text= result[0];
.text = result[1];
.text =result[2];
.text=result[3];
List<string[]> groups=new List<string[]>();
int startIndex = 4;
int ramainingLength = result.Length - startIndex;
int groupCount = ramainingLength / 3;
groups.Capacity = groupCount;
for (int i = 0; i < groupCount; i++)
{
int baseIndex = startIndex + (i * 3);
string[] group = new string[3];
group[0] = result[baseIndex];
group[1] = result[baseIndex + 1];
group[2] = result[baseIndex + 2];
groups.Add(group);
}
Debug.Log(groups.Count);
for (int j = 0; j < groups.Count; j++)
{
itemPra.GetChild(j).GetChild(0).GetComponent<TextMeshProUGUI>().text = groups[j][0];
itemPra.GetChild(j).GetChild(1).GetComponent<TextMeshProUGUI>().text = groups[j][1];
itemPra.GetChild(j).GetChild(2).GetComponent<TextMeshProUGUI>().text = groups[j][2];
}
//for (int k = 1; k < dataLength; k++)
//{
// result[k*3+1]
// QiXiangData data = new QiXiangData();
// data.index=
//}
//for (int i = 0; i < itemPra.childCount; i++)
//{
// for (int j = 0; j < 3; j ++)
// {
// itemPra.GetChild(i).GetChild(j).GetComponent<TextMeshProUGUI>().text=
// }
//}
}
// Update is called once per frame
void Update()
{
}
}
public class QiXiangData
{
public string index;
public string sppedAndJoy;
public string xuwen;
}