Data from text files into variables
How can data from a text file be stored in variables? Lets say my text file says this:
x = 2;
y = 4;
name = "username"
And my script says this:
int y;
int x;
string name;
How can i read the data from my text file, and then store the data into the integers and strings?
Answer by JedBeryll · Jan 23, 2016 at 09:19 PM
That is deserialization. You could use a JSON serializer to do this for you but this will only work if it has the right format so you would have to create this file with JSON serializer in the first place. Other than that you can write your own serializer but i know from experience that is a major pain in the rear (not that it wasn't worth it though). If you insist on creating your own then look into System.Reflection. https://msdn.microsoft.com/en-us/library/ms173183.aspx
Could you explain to me how a serializer works and how I could use it in this situation? I plan to save stuff like arrays, ints, and strings.
I wrote my own serializer so i don't have experience with JSON but here is a nice explanation: http://wiki.unity3d.com/index.php/SimpleJSON
Your answer
Follow this Question
Related Questions
Writing save files (JavaScript) 0 Answers
i can't see my text 0 Answers
how can I save text to input field with button? 1 Answer
Help with making interactive text animation for a 2D game 0 Answers