Esempio n. 1
0
    public static ConversationJSON CreateFromJSON(string conversationStr)
    {
        // Debug.Log("Convo Str: " + conversationStr);
        JSONNode         node             = JSON.Parse(conversationStr);
        ConversationJSON conversationJSON = JsonUtility.FromJson <ConversationJSON>(node.ToString());

        conversationJSON.conversationTree = ConversationTreeJSON.CreateFromJSON(node["conversationTree"].ToString());
        return(conversationJSON);
    }
Esempio n. 2
0
    public static ConversationTreeJSON CreateFromJSON(string treeStr)
    {
        // Debug.Log("Tree String: " + treeStr);
        JSONNode             node     = JSON.Parse(treeStr);
        ConversationTreeJSON treeJSON = JsonUtility.FromJson <ConversationTreeJSON>(node.ToString());

        // Prompts
        treeJSON.prompts = new List <ConversationPromptJSON>();
        foreach (JSONNode promptNode in node["prompts"].AsArray)
        {
            treeJSON.prompts.Add(ConversationPromptJSON.CreateFromJSON(promptNode.ToString()));
        }
        // Responses
        treeJSON.responses = new List <ConversationResponseJSON>();
        foreach (JSONNode responseNode in node["responses"].AsArray)
        {
            treeJSON.responses.Add(ConversationResponseJSON.CreateFromJSON(responseNode.ToString()));
        }

        return(treeJSON);
    }