using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
public class ReadEditorInfo : MonoBehaviour
{ //传值对象为字符串
string ContentInfo;//存储输入的文本内容
string[] con;//将输入的文本信息存储到数组中
private GameObject[] ReadInfo;//存储分割后字符串的数组
//显示信息的Text
public List<GameObject> textInfoShow = new List<GameObject>();
public void ReadInfoFunc(string conten, char split)
{ //方法1:用于字符串的传值
this.ContentInfo = conten;
//";" 切割字符串的标志
string[] ReadInfo = ContentInfo.Split(new char[] { split });
for (int i = 0; i < textInfoShow.Count; i++)
{
int j = i;
textInfoShow[j].GetComponent<Text>().text = ReadInfo[j];
if (textInfoShow[j].GetComponent<Text>().text == "")
{
textInfoShow[j].GetComponent<Text>().text = "获取信息失败";
}
}
}
public void ReadInfoFunc(string[] conten)
{ //方法2:传值对象为字符串数组
this.con = conten;
for (int i = 0; i < textInfoShow.Count; i++)
{
textInfoShow[i].GetComponent<Text>().text = con[i];
if (textInfoShow[i].GetComponent<Text>().text == "")
{
textInfoShow[i].GetComponent<Text>().text = "获取信息失败";
}
}
}
}