void ReadFromJson(string fileLocation) { string input = File.ReadAllText(fileLocation); print(input); currentNode = JsonUtility.FromJson <QANode>(input); }
void ReadFromJson(string fileLocation) //convert .Json text into text in current node { string Input = File.ReadAllText(fileLocation); //print(Input); currentNode = JsonUtility.FromJson <QANode>(Input); }
void WriteNewJson(string fileLocation) { currentNode = new QANode( 1, "You come to a fork in the road.\n There is also a spoon here.", "Take fork", "Take Spoon"); string JsonStr = JsonUtility.ToJson(currentNode, true); //print(JsonStr); File.WriteAllText(fileLocation, JsonStr); }
void WriteNewJson(string fileLocation) { currentNode = new QANode( 1, "You come to a fork in the road.\n Do you go left or right?", "Left", "Right"); string jsonStr = JsonUtility.ToJson(currentNode, true); print(jsonStr); File.WriteAllText(fileLocation, jsonStr); //pretty printing kills mobile data quotas // currentNode.pageNumber = 1; // currentNode.questionText = "You come to a fork in the road.\n Do you go left or right?"; // currentNode.option1Text = "Left"; // currentNode.option2Text = "Right"; }
void WriteNewJson(string fileLocation) { currentNode = new QANode( 1, "You come to a fork in the road.\n Do you got left or right?", "left", "right"); // currentNode.pageNumber = 1; // currentNode.questionText = "You come to a fork in the road.\n Do you got left or right?"; // currentNode.option1Text = "left"; // currentNode.option2Text = "right"; string jsonStr = JsonUtility.ToJson(currentNode, true); print(jsonStr); File.WriteAllText(fileLocation, jsonStr); }
void ReadFromJson(string fileLocation) //read in all the Json { if (jsonArray == null) //if we haven't loaded the json into jsonArray already { string input = File.ReadAllText(fileLocation); //get the json text out of the file print(input); jsonArray = JSON.Parse(input) as JSONArray; //parse the json from the text and put it into jsonArray } QANode qaNode = new QANode(); //make a new QANode qaNode.pageNumber = jsonArray[jsonIndex][JSON_PAGE_NUM].AsInt; //get the pageNumber from by qaNode.questionText = jsonArray[jsonIndex][JSON_QUESTION]; //get the question text qaNode.option1Text = jsonArray[jsonIndex][JSON_OPT1_TEXT]; //get the text for option1 qaNode.option2Text = jsonArray[jsonIndex][JSON_OPT2_TEXT]; //get the text for option2 currentNode = qaNode; //make the current node the node we just set up from the JSON }
void UpdateUI(QANode node) //update the UI gameObjects to match the info in the node passed to this function { questionText.text = node.questionText; option1Text.text = node.option1Text; option2Text.text = node.option2Text; }
void UpdateUI(QANode node) { questionText.text = node.questionText; option1Text.text = node.option1Text; option2Text.text = node.option2Text; }
void UpdateUI(QANode node) //update UI text according to our current QA node { questionText.text = node.questionText; option1Text.text = node.option1Text; option2Text.text = node.option2Text; }