It is not possible to load the variables with PlayerPrefs because if I use PlayPrefs I have to save the variables before. In my example the variables are stored in a textfile which comes with the application.
When I build to iPhone, it does not read the file just like you said. How do I revise this code so the iphone can read my txt file.
Here is my code (i have commented out different methods I have tried (which don’t work on the iphone) DictionaryFile (commented out) is a textasset. Still wont work.
void ParseDict()
{
//string path = @"Assets/Dictionary.txt";
//string path = DictionaryFile.text;
string path = Application.dataPath + "/Text/Dictionary.txt";
try
{
// Create an instance of StreamReader to read from a file.
// The using statement also closes the StreamReader.
using (StreamReader sr = new StreamReader(path))
{
string line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
dictionary.Add(line, line);
}
}
}
catch (System.Exception e)
{
// Let the user know what went wrong.
UnityEngine.Debug.Log("The file could not be read:");
UnityEngine.Debug.Log(e.Message);
}
}