The question is answered, right answer was accepted
Saved data to .txt file is returning null
Hi everyone.
I am trying here to save some data to a .txt file but what is saved to the file are just "nulls".
Here's the relevant code:
public GameObject companyName;
public GameObject ownerName;
public GameObject location;
public void saveData(string doc)
{
using (StreamWriter writer = new StreamWriter(@"C:\Users\Public\Documents\AGS\Saves\Slot1.txt"))
{
writer.Write(companyName.GetComponent<GUIText>() + ", ");
writer.Write(ownerName.GetComponent<GUIText>() + ", ");
writer.Write(location.GetComponent<GUIText>() + ", ");
writer.Close();
}
}
And what returns into the .txt file is that : null, null, null,
The data I am trying to save is typed into the Input Text.
There's some time I am trying to figure out what is going on but I can't see the problem... Well, that's all, thanks.
Answer by doublemax · Oct 07, 2016 at 11:51 PM
companyName.GetComponent<GUIText>() is just the component. companyName.GetComponent<GUIText>().text returns the text
Hey guy, really really thanks, I felt a little fool for don't had noticed that... well, thanks.
Follow this Question
Related Questions
Annotations and Screenshots not lining up 0 Answers
Is there any tutorials on using MySQL and Unity? 0 Answers
What is the best way to achieve local database for mobile? 0 Answers
Some help with Data Save/Load would be most appreciated 3 Answers
Save multiple inputs for one item and print out all items 0 Answers