Text Field Not Taking Inputs

This is essentially a follow up question, so apologies to all for not being clear in my original post. Thanks AldoNaletto for the answer to my previous post.

We’re putting together a sim that allows users to set their own prices for a catalogue of items. We’ve got it set up now so that we’re iterating through a built-in array to show the Text Fields on-screen. So, we allocate a first round of default numbers to the array using:

   		stringToEdit _= GUILayout.TextField (stringToEdit*, 5, GUILayout.Width(50));*_

Then we parse the string to a float, etc. However, the user needs to be able to edit the string to put in their own price. This is where we’re stuck. Is it possible to edit the text field the way it is currently set up? Right now nothing happens when we try to type in a value.

I don’t know what you’ve done to make it not work.
Do you have any errors in console?

Basically I see three scenarios:

  1. Your GUI code is not in OnGUI.
  2. Your stringToEdit array is, or contain null.
  3. You are updating stringToEdit elsewhere, overwriting the values.

I wrote a basic example to show how it should work.

using UnityEngine;

public class TextFieldExample : MonoBehaviour
{
    string[] stringToEdit;

    void Awake()
    {
        stringToEdit = new string[10];
        for (int i = 0; i < stringToEdit.Length; ++i)
            stringToEdit *= string.Empty;*

}

void OnGUI()
{
for (int i = 0; i < stringToEdit.Length; ++i)
stringToEdit = GUILayout.TextField(stringToEdit*, 5, GUILayout.Width(50));*
}
}