Exemple #1
0
        public JSONTemplate GetJSONObject()
        {
            JSONTemplate json = new JSONTemplate();

            json.AddKeyValue("fromId", this.outPoint.node.GetId());
            json.AddKeyValue("toId", this.inPoint.node.GetId());
            return(json);
        }
        public override JSONTemplate GetJSONObject()
        {
            JSONTemplate json = new JSONTemplate();

            json.AddKeyValue("type", "end");
            json.AddKeyValue("posX", this.GetPosition().x);
            json.AddKeyValue("posY", this.GetPosition().y);
            return(json);
        }
Exemple #3
0
        public virtual JSONTemplate GetJSONObject()
        {
            JSONTemplate json = new JSONTemplate();

            json.AddKeyValue("type", "dialogue");
            json.AddKeyValue("name", this.nameInput);
            json.AddKeyValue("dialogue", this.dialogueInput);
            json.AddKeyValue("posX", this.GetPosition().x);
            json.AddKeyValue("posY", this.GetPosition().y);
            return(json);
        }
    public IEnumerator GetData()
    {
        using (var www = UnityWebRequest.Get(apiAddress))
        {
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log("Network Error");
            }
            if (www.responseCode == 200)
            {
                parsedOBJ = JsonUtility.FromJson <JSONTemplate>(www.downloadHandler.text);
                RenderAngles(parsedOBJ);
            }
        }
    }
 private void RenderAngles(JSONTemplate parsedOBJ)
 {
     if (!parsedOBJ.keypoints[2].isdummy)
     {
         InitialAngles[0] += new Vector3(0, 0, parsedOBJ.keypoints[2].angle);
     }
     if (!parsedOBJ.keypoints[3].isdummy)
     {
         InitialAngles[1] += new Vector3(0, 0, parsedOBJ.keypoints[3].angle);
     }
     if (!parsedOBJ.keypoints[4].isdummy)
     {
         InitialAngles[4] = new Vector3(0, 0, parsedOBJ.keypoints[4].angle);
     }
     if (!parsedOBJ.keypoints[5].isdummy)
     {
         InitialAngles[5] = new Vector3(0, 0, parsedOBJ.keypoints[5].angle);
     }
 }
        private void Export()
        {
            string fileName     = openFileName;
            string path         = EditorUtility.SaveFilePanel("Save file", "", openFileName, "json");
            string saveFileName = Path.GetFileName(path);

            if (path.Length > 0)
            {
                Story story = new Story();
                story.storyName = fileName;
                story.author    = authorInput;
                JSONTemplate json = new JSONTemplate();
                json.AddKeyValue("storyName", story.storyName);
                json.AddKeyValue("author", story.author);
                JSONTemplate nodeJSON  = new JSONTemplate();
                int          currentId = 0;
                foreach (StoryNode node in nodes)
                {
                    nodeJSON.AddChildJSON("" + currentId, node.GetJSONObject());
                    node.SetId(currentId);
                    currentId += 1;
                }
                json.AddChildJSON("nodes", nodeJSON);

                currentId = 0;
                JSONTemplate connectionsJSON = new JSONTemplate();
                foreach (Connection connection in connections)
                {
                    connectionsJSON.AddChildJSON("" + currentId, connection.GetJSONObject());
                    currentId += 1;
                }

                json.AddChildJSON("connections", connectionsJSON);

                File.WriteAllText(path, json.GetJSON());
            }
        }