Ejemplo n.º 1
0
    /// <summary>
    /// Reads the questions json and stores them into text assets.
    /// </summary>
    List <Question> ReadQuestions(List <Snippet> answers)
    {
        var    loadedData = new QuestionData();
        string filePath   = Path.Combine(Application.streamingAssetsPath, "Questions.json");

        Debug.Log("Path:" + filePath);
        if (File.Exists(filePath))
        {
            string dataAsJson = File.ReadAllText(filePath);
            loadedData = JsonUtility.FromJson <QuestionData>(dataAsJson);
        }
        else
        {
            Debug.LogError("Cannot find file!");
        }

        return(loadedData.ConvertToQuestions(answers));
    }