This is my Code
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
public class PlayerName : MonoBehaviour
{
public string theName;
public Text inputField, textDisplay;
[Space]
public List<string> storedPlayerNames = new List<string>();
public void StoreName()
{
theName = inputField.text;
textDisplay.text = textDisplay.text + "
" + theName;
if (storedPlayerNames.Contains(theName))
Debug.LogWarning(theName + " already exists", this);
else
{
storedPlayerNames.Add(theName);
Debug.Log("New player added: " + theName);
}
}
}