I am trying to write code that stores a list of strings, and then gets each one individually in a for loop. However, I keep receiving the following error:
Cannot implicitly convert type `string' to `System.Collections.Generic.List<string>'
I have set the code to take the string only from the list but the error persists.
List<string> textName = new List<string>();
void OnGUI()
{
for(int i = 0; i < texts; i++)
{
string tn = textName*;*
textName = GUILayout.TextField(tn); // Name - I have also tried tn.ToString() with the exact same results.
}
}
I don’t understand why I am receiving this error.
Also, using a (string) cast doesn’t work either.
Edit: Using .ToString() does not resolve the issue, and also using Arrays instead of lists produces a similar error involving the inability to convert string to string[].
This script is an editor script (extends from EditorWindow), could this be the cause of the issue?