Ejemplo n.º 1
0
    //recreate tour from json
    public void Import()
    {
        SavedTour savedTour = JsonUtility.FromJson <SavedTour>(result);

        foreach (SavedPanorama saved_panorama in savedTour.saved_panoramas.list)
        {
            GameObject new_panorama          = Instantiate(panorama_prefab, saved_panorama.position, saved_panorama.rotation) as GameObject;
            Panorama   new_panorama_panorama = new_panorama.GetComponent <Panorama>();
            new_panorama_panorama.id   = saved_panorama.id;
            new_panorama_panorama.link = saved_panorama.link;
            tour.panoramas.Add(new_panorama_panorama);
            new_panorama_panorama.Download();
        }
        foreach (SavedPhoto saved_photo in savedTour.saved_photos.list)
        {
            GameObject new_photo       = Instantiate(photo_prefab, saved_photo.position, saved_photo.rotation) as GameObject;
            Photo      new_photo_photo = new_photo.GetComponent <Photo>();
            new_photo_photo.id          = saved_photo.id;
            new_photo_photo.panorama_id = saved_photo.panorama_id;
            new_photo_photo.link        = saved_photo.link;
            tour.interactions.Add(new_photo_photo);
            new_photo_photo.Download();
        }
        foreach (SavedTransition saved_transition in savedTour.saved_transitions.list)
        {
            GameObject new_transition            = Instantiate(transition_prefab, saved_transition.position, saved_transition.rotation) as GameObject;
            Transition new_transition_transition = new_transition.GetComponent <Transition>();
            new_transition_transition.id          = saved_transition.id;
            new_transition_transition.panorama_id = saved_transition.panorama_id;
            new_transition_transition.target_id   = saved_transition.target_id;
            new_transition_transition.tour        = tour;
            tour.interactions.Add(new_transition_transition);
        }

        tour.Move(0);
    }