using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour {
public Text text;
public Button button;
public InputField inputField;
private string s;
private string w;
private string[] str;
void Awake()
{
str = new string[5];
}
void Update()
{
Input();
}
public void Btn()
{
if (!string.IsNullOrEmpty(inputField.text))
{
for (int i = 0; i < str.Length; i++)
{
if (str[i] == null)
{
str[i] = s;
break;
}
if (str[4]!=null)
{
for (int j = 1; j < str.Length; j++)
{
str[j - 1] = str[j];
}
str[4] = null;
}
}
for (int i = 0; i < str.Length; i++)
{
if (str[i]!=null)
{
w+= str[i]+"\n" ;
}
}
text.text = w;
w = null;
inputField.text = null;
}
}
public void Input()
{
if (!string.IsNullOrEmpty(inputField.text))
{
s = inputField.text;
}
else
{
return;
}
}
}