public void draw(string path, float stemY, float gap, float startX, float endX) // This function draws the timeline recursively.
    {
        Debug.Log(path);
        float videoLength = 0;

        if (recur_depth == 0)
        {
            rootpath = path;
        }

        string assumed_videopath = Path.Combine(path, "MainVideo.mp4");

        Debug.Log(assumed_videopath);
        if (File.Exists(@assumed_videopath) && recur_depth < 3)
        {
            recur_depth++;
            string json_path = System.IO.Path.Combine(path, "hotspots.json");
            Debug.Log(json_path);
            string       hotspotjsons = System.IO.File.ReadAllText(@json_path);
            HotspotDatas hotspotdatas = JsonUtility.FromJson <HotspotDatas>(hotspotjsons);
            double       largest_end  = 10;
            foreach (string json in hotspotdatas.hotspotdatas)
            {
                HotspotData h = JsonUtility.FromJson <HotspotData>(json);
                if (h.end_time > largest_end)
                {
                    largest_end = h.end_time;
                }
            }
            videoLength = (float)largest_end + 20;

            foreach (string json in hotspotdatas.hotspotdatas)
            {
                HotspotData h             = JsonUtility.FromJson <HotspotData>(json);
                float       xpos          = (float)(startX + ((endX - startX) * (h.start_time / videoLength)));
                GameObject  tree_node     = window_Graph.CreateCircle(new Vector2(xpos, stemY), h.name + "c");
                string      tree_node_id  = tree_node.GetInstanceID().ToString();
                string      relative_path = "";
                if (recur_depth > 1)
                {
                    relative_path = path.Substring(rootpath.Length);
                }
                GotoHelper helper = new GotoHelper(relative_path, h.worldPosition, h.start_time);
                timeline_dictionary.Add(tree_node_id, helper);
                Debug.Log(h.url_video);
                if ((h.url_video != null) && (h.url_video != ""))
                {
                    float gap2 = (float)(gap * (1 - (h.start_time / videoLength)));
                    window_Graph.CreateDotConnection(new Vector2(xpos, stemY), new Vector2(xpos, stemY + gap2), h.name);
                    window_Graph.CreateDotConnection(new Vector2(xpos, stemY + gap2), new Vector2(endX, stemY + gap2), h.name + "l");
                    draw(@Path.Combine(path, h.name), stemY + gap2, (gap / 2), xpos, endX);
                }
            }
        }
    }
Exemple #2
0
    public void load()
    {
        table = new Hashtable();
        string json_path = System.IO.Path.Combine(statusController.getPath(), "hotspots.json");

        Debug.Log(json_path);
        if (File.Exists(json_path))
        {
            string       hotspotjsons = File.ReadAllText(json_path);
            HotspotDatas hotspotdatas = JsonUtility.FromJson <HotspotDatas>(hotspotjsons);
            foreach (string json in hotspotdatas.hotspotdatas)
            {
                HotspotData h1 = JsonUtility.FromJson <HotspotData>(json);
                GameObject  a  = Instantiate(hotspot, h1.worldPosition, h1.rot);
                a.name = a.GetInstanceID().ToString();
                table.Add(a.GetInstanceID().ToString(), new Hotspot(a, h1.start_time, h1.end_time, h1.name, h1.text, h1.url_photo, h1.url_video));
            }
            hotspots_loaded = true;
        }
    }
Exemple #3
0
    //Load hotspots from json file.
    public void load()
    {
        all_hotspots = new Hashtable();
        string json_path = System.IO.Path.Combine(statusController.getPath(), "hotspots.json");

        Debug.Log(json_path);
        if (File.Exists(json_path))
        {
            string       hotspotjsons = File.ReadAllText(json_path);
            HotspotDatas hotspotdatas = JsonUtility.FromJson <HotspotDatas>(hotspotjsons);
            foreach (string json in hotspotdatas.hotspotdatas)
            {
                HotspotData h1 = JsonUtility.FromJson <HotspotData>(json);
                GameObject  a  = Instantiate(hotspot, h1.worldPosition, h1.rot);
                a.name = a.GetInstanceID().ToString();
                all_hotspots.Add(a.GetInstanceID().ToString(), new Hotspot(a, h1.start_time, h1.end_time, h1.name, h1.text, h1.url_photo, h1.url_video));
                //window_Graph.CreateDotConnection(new Vector2((float)((h1.start_time / videoPlayer.length) * 1850 + 100), 150), new Vector2((float)((h1.start_time / videoPlayer.length) * 1850 + 100) + 100, 250), a.GetInstanceID().ToString());
                //window_Graph.CreateCircle(new Vector2((float)((h1.start_time / videoPlayer.length) * 1850 + 100) + 100, 150 + 100), a.GetInstanceID().ToString() + "c");
            }
            hotspots_loaded = true;
        }
    }
Exemple #4
0
    public void save(Hashtable a)
    {
        Debug.Log("Saving");
        List <string> jsonlist = new List <string>();

        foreach (DictionaryEntry entry in a)
        {
            Hotspot     h1 = (Hotspot)entry.Value;
            HotspotData h2 = new HotspotData(h1.getStart(), h1.getEnd(), h1.getName(), h1.getText(), h1.getUrl_photo(), h1.getUrl_video(), h1.getHotspot());
            string      h3 = JsonUtility.ToJson(h2);
            jsonlist.Add(h3);
        }
        string[] jsons = new string[jsonlist.Count];
        jsons = jsonlist.ToArray();
        HotspotDatas hotspotdatas = new HotspotDatas()
        {
            hotspotdatas = jsons
        };
        string json = JsonUtility.ToJson(hotspotdatas);

        //Debug.Log(json);
        File.WriteAllText(Application.dataPath + "/hotspots.json", json);
    }