Example #1
0
    private void LoadQuestions()
    {
        using (StreamReader stream = new StreamReader(questionPath))
        {
            string json = stream.ReadToEnd();
            questionCollection = JsonUtility.FromJson <QuestionCollection>(json);
        }

        Debug.Log("Questions Loaded: " + questionCollection.questions.Length);
        FindObjectOfType <Text>().text = questionCollection.ToString();
    }
Example #2
0
    void LoadQuestions()
    {
        // reads the file with path "questionPath" and closes it automatically
        // after its done
        using (StreamReader reader = new StreamReader(questionPath))
        {
            // extract and store the entire file in a string
            string json = reader.ReadToEnd();

            // deserialize that string data into our question collection object
            questionCollection = JsonUtility.FromJson <QuestionCollection>(json);
        }

        print("Questions loaded: " + questionCollection.questions.Length);
        words.text = questionCollection.ToString();
    }