- Home /
GUILayout Textfield not editable just static
Hey,,
I am having trouble with my code with in each count it's suppose to view the items as a editable textfield but instead it shows row text in the OnGUI method
here is the code //Just some basic styles for the items
GUIStyle itemsContent = new GUIStyle (GUI.skin.textArea);
itemsContent.fontSize= 14;
Color32 textcolor = new Color32 (139,90,43,255);
itemsContent.normal.textColor = textcolor;
itemsContent.normal.background = null;
itemsContent.hover.textColor= textcolor;
GUI.backgroundColor = Color.clear;
//for loop for getting items and setting them for the user
for(cnt = 0 ; cnt < numofLabels ; cnt++){
GUI.backgroundColor = Color.yellow;
itemTemp = items[cnt].getItms(); // array which has items from DB
GUI.Box(new Rect(610,200+(70*cnt),260,70),"Items List: " + GUILayout.TextField(itemTemp,25) +"\n",itemsContent);
}
Thank you so much
Answer by robhuhn · Dec 06, 2013 at 03:22 PM
GUILayout.TextField() can not be concatenated with strings **. You need to place the gui items next to each other manually.
E.g.
GUILayout.BeginArea(new Rect(610,200,260,70));
{
GUILayout.BeginVertical();
{
for(cnt = 0 ; cnt < numofLabels ; cnt++)
{
GUI.backgroundColor = Color.yellow;
itemTemp = items[cnt].getItms();
GUILayout.BeginHorizontal();
{
GUILayout.Box("Items List: ", itemsContent);
itemTemp = GUILayout.TextField(itemTemp,25);
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
}
GUILayout.EndArea();
*not tested
I'm not sure if itemTemp is a string or something else but I guess you want to store it again after it was edited.
@Edit ** actually the return value can be concatenated but the returned string isn't stored then afaik
i tried your code but now nothing shows it just shows items list :(
i am trying to make a list of editable items using guiLayout.textfield but my code logic seems invalid
Your answer
Follow this Question
Related Questions
Sideways textfield 1 Answer
TextField does not show up 2 Answers
Instantiating a text field 0 Answers
Styling an individual button in SelectionGrid 0 Answers
Text fields where text will scale along with resolution. 1 Answer