Reading from a builtin file

I am working on a flashcards project. I have a Greek word and its English definition. There may be hundreds of words. Can someone recommend a storage and retrieval mechanism?

Thanks.

If you want it built into your app, you could simply use a TextAsset.

1 Like

A simple csv loaded with System.IO would do the job. But as things got bigger you might want to break it up into a more efficient structure. Still, you could get a lot of words this way before its time to panic.

Thanks. I decided to use TextAsset and code like this:

public class Populate : MonoBehaviour
{

    public Text flashText;
    public Text answerText;


    public TextAsset theFile;

    List<string> questions = new List<string>();
    List<string> answers = new List<string>();
   
   
    void GetGreekAndEnglish(ref List<string> greekWords, ref List<string> englishWords)
    {
       
   
        string wholeFile = theFile.text;
       
        string[] lines = wholeFile.Split ('\n');
       
        int numLines = lines.Length;
       
        for (int ctr = 0; ctr <  numLines; ctr++)
        {
           
            string theLine = lines[ctr];
            string[] theValues = theLine.Split(',');
           
            greekWords.Add(theValues[1]);
            englishWords.Add(theValues[2]);

        }
       
    }
1 Like