- Home /
Question by
Thet Naing Swe · Nov 16, 2010 at 04:51 PM ·
textfieldeditorguilayout
EditorGUILayout textfield return value problem
Hi, How can I make the EditorGUILayout textfield to return the correct string value?
string levelPath = "C:\\Levels\\LevelTest.txt";
levelPath = EditorGUILayout.TextField(levelPath);
print(levelPath);
for the above code, Whatever I type in my textfield, levelPath just return "C:\Levels\LevelTest.txt"... Any idea to fix this?
Comment
Best Answer
Answer by Tetrad · Nov 16, 2010 at 04:57 PM
// outside the function string levelPath = "C:\\Levels\\LevelText.txt";
void OnGUI() { levelPath = EditorGUILayout.TextField(levelPath); print(levelPath); }
The problem is you're re-initializing the variable every time. You need to make it a member variable and not continuously re-assign it.