コード例 #1
0
    public void ReadData()
    {
        try
        {
            if (System.IO.File.Exists(path))
            {
                string      contents = System.IO.File.ReadAllText(path);
                JSONwrapper wrapper  = JsonUtility.FromJson <JSONwrapper>(contents);
                projectData = wrapper.triggers;

                foreach (TriggerData s in projectData.triggers)
                {
                    int t = s.trigger;
                    Debug.Log("Trigger = " + t);

                    string i = s.input;
                    Debug.Log("input = " + i);

                    string o = s.output;
                    Debug.Log("output = " + o);
                }
            }
            else
            {
                Debug.Log("Unable to read the save data, file does not exist");
            }
        }
        catch (System.Exception ex)
        {
            Debug.Log(ex.Message);
        }
    }
コード例 #2
0
ファイル: Run.cs プロジェクト: AlifDanial/Proto.IoT
 // Start is called before the first frame update
 void Start()
 {
     if (System.IO.File.Exists(path))
     {
         string      contents = System.IO.File.ReadAllText(path);
         JSONwrapper wrapper  = JsonUtility.FromJson <JSONwrapper>(contents);
         projectData = wrapper.triggers;
     }
 }
コード例 #3
0
ファイル: Run.cs プロジェクト: AlifDanial/Proto.IoT
    public void setPath(string s)
    {
        path = s;

        if (System.IO.File.Exists(path))
        {
            string      contents = System.IO.File.ReadAllText(path);
            JSONwrapper wrapper  = JsonUtility.FromJson <JSONwrapper>(contents);
            projectData = wrapper.triggers;
        }

        Sensor.GetComponent <ConnectToServer>().SensorData = "EMPTY";
        stop = false;
        ri.gameObject.SetActive(false);
        audiosI.gameObject.SetActive(false);
        audiostext.enabled = false;
    }
コード例 #4
0
    void SaveData()
    {
        JSONwrapper wrapper = new JSONwrapper();

        wrapper.triggers = projectData;
        string contents = JsonUtility.ToJson(wrapper, true);

        System.IO.File.WriteAllText(path, contents);

        if (temp != path && loaded == false)
        {
            temp = path;
            sm.setSave(path);
            sm.readPath();
        }

        run.setPath(path);
        run.enabled = true;
        //ReadData();
    }
コード例 #5
0
    public void loadFile(string path)
    {
        dm.loaded = true;

        try
        {
            if (System.IO.File.Exists(path))
            {
                string      contents = System.IO.File.ReadAllText(path);
                JSONwrapper wrapper  = JsonUtility.FromJson <JSONwrapper>(contents);
                projectData = wrapper.triggers;

                foreach (TriggerData s in projectData.triggers)
                {
                    int t = s.trigger;
                    Debug.Log("Trigger = " + t);

                    loadInput = s.input;

                    loadOutput = s.output;


                    if (s.input == "Motion")
                    {
                        if (s.outputType == "Audio")
                        {
                            recreate(2, 1);
                        }
                        else if (s.outputType == "Image")
                        {
                            recreate(2, 2);
                        }
                        else if (s.outputType == "Video")
                        {
                            recreate(2, 3);
                        }
                        else
                        {
                            recreate(2, 4);
                        }
                    }

                    else if (s.input.Contains("Touch"))
                    {
                        if (s.outputType == "Audio")
                        {
                            recreate(3, 1);
                        }
                        else if (s.outputType == "Image")
                        {
                            recreate(3, 2);
                        }
                        else if (s.outputType == "Video")
                        {
                            recreate(3, 3);
                        }
                        else
                        {
                            recreate(3, 4);
                        }
                    }

                    else if (s.input.Contains("Card"))
                    {
                        if (s.outputType == "Audio")
                        {
                            recreate(1, 1);
                        }
                        else if (s.outputType == "Image")
                        {
                            recreate(1, 2);
                        }
                        else if (s.outputType == "Video")
                        {
                            recreate(1, 3);
                        }
                        else
                        {
                            recreate(1, 4);
                        }
                    }
                }
            }
            else
            {
                Debug.Log("Unable to read the save data, file does not exist");
            }
        }
        catch (System.Exception ex)
        {
            Debug.Log(ex.Message);
        }
    }