Ejemplo n.º 1
0
    private void Awake()
    {
        if (instance == null)
        {
            DontDestroyOnLoad(gameObject);
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        #region populate all arrays/lists using our .json files

        _questionJson = Application.streamingAssetsPath + "/Text/AllQuestions.json"; //find location of AllQuestions.json
        string allQuestionText = File.ReadAllText(_questionJson);                    //read all the text in that .json file
        questionData = QuestionData.CreatFromJson(allQuestionText);                  //convert text in that .json file into something that Unity can read
        //(in this case, an object containing a List of strings)

        questionPool = questionData.questionPool.questions;                      //initialize our List variable as the List of strings in our .json file

        _answerJson = Application.streamingAssetsPath + "/Text/AllAnswers.json"; //find location of AllAnswers.json
        string allAnswerText = File.ReadAllText(_answerJson);                    //read all the text in that .json file
        characterData = CharacterData.CreateFromJson(allAnswerText);             //convert text in that .json file into something that Unity can read
        //(in this case, an array of objects, each containing a string name, and a List of string answers)

        _endingJson = Application.streamingAssetsPath + "/Text/AllEndings.json"; //find location of AllEndings.json
        string allEndingText = File.ReadAllText(_endingJson);                    //read all the text in that .json file
        endingData = EndingData.CreateFromJson(allEndingText);                   //convert text in that .json file into something that Unity can read
        //(in this case, an array of objects, each containing a string name, and an array of string parings)

        #endregion
    }
Ejemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        _questionJson = Application.dataPath + "/Text/AllQuestions.json";
        string allQuestionText = File.ReadAllText(_questionJson);

        questions = QuestionData.CreatFromJson(allQuestionText);

        questionPool = questions.questionPool.questions;

        _answerJson = Application.dataPath + "/Text/AllAnswers.json";
        string allAnswerText = File.ReadAllText(_answerJson);

        characterData = AllResponses.CreateFromJson(allAnswerText);

        UpdateUI();

        //WriteNewJson(fileLocation); //use to creat new Json file, if file does not already exist.
    }