public void Init(VideoSourceModel videoSourceModel, int camCount)
    {
        this.gameObject.SetActive(true);
        this.videoSourceModel = videoSourceModel;

        if (videoSourceModel.points == null)
        {
            videoSourceModel.points = new List <CamPoseModel>();
        }

        while (videoSourceModel.points.Count < camCount)
        {
            float pos = -9 + videoSourceModel.points.Count * 6;
            videoSourceModel.points.Add(new CamPoseModel()
            {
                id = videoSourceModel.points.Count.ToString(), position = new Vector3(pos, -3.0f, 20.6f)
            });
        }

        foreach (Transform tr in pointContainer)
        {
            Destroy(tr.gameObject);
        }

        int i = 0;

        foreach (CamPoseModel camPoseModel in videoSourceModel.points)
        {
            GameObject go = Instantiate(pointRendererPrefab);
            go.transform.SetParent(pointContainer, false);
            PosRendererElement posRenderer = go.GetComponent <PosRendererElement>();
            posRenderer.Init(camPoseModel);
            i++;
        }
    }
    public void Init(VideoSourceModel videoSource, SourceManager delayTime)
    {
        foreach (Transform item in content.transform)
        {
            Destroy(item.gameObject);
        }

        foreach (CamPoseModel model in videoSource.points)
        {
            GameObject  go          = Instantiate(camPoseObject);
            VideoButton videoButton = go.GetComponent <VideoButton>();
            go.transform.SetParent(content.transform, false);
            videoButton.Init(model);
        }
        content.SetActive(false);
        string fileName = Application.persistentDataPath + "/Documents/video_" + videoSource.id + ".mp4";

        if (!File.Exists(fileName))
        {
            return;
        }

        videoPlayer.url = fileName;

        this.transform.rotation = Quaternion.Euler(0, -90, 0);
    }
        public void RmoveItem(VideoSourceModel model)
        {
            sourceManager.RemoveItem(model);
            string fileName = Application.persistentDataPath + "/Documents/video_" + model.id + ".mp4";

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
        }
예제 #4
0
    public bool AddItem(VideoSourceModel item)
    {
        if (sources.ContainsKey(item.id))
        {
            return(false);
        }

        sources.Add(item.id, item);
        CheckPoses();
        return(true);
    }
        private void OnAddButtonClick()
        {
            int lastId = GetLastId();
            VideoSourceModel videoSourceModel = new VideoSourceModel()
            {
                id = lastId.ToString(),
            };

            bool added = sourceManager.AddItem(videoSourceModel);

            if (added)
            {
                Refresh();
            }
        }
예제 #6
0
    public bool RemoveItem(VideoSourceModel item)
    {
        bool result = sources.Remove(item.id);

        Debug.Log($"remove item at {item.id} with result: { result} ");
        if (!result)
        {
            return(false);
        }

        foreach (VideoSourceModel checkItem in sources.Values)
        {
            foreach (CamPoseModel camPoseModel in checkItem.points)
            {
                if (camPoseModel.id == item.id)
                {
                    checkItem.points.Remove(camPoseModel);
                    return(true);
                }
            }
        }
        return(true);
    }
예제 #7
0
        public void Init(VideoSourceModel videoSourceModel, VideoSourcesPanel videoSourcesPanel)
        {
            id.text        = videoSourceModel.id;
            linkField.text = videoSourceModel.path;

            loadButton.onClick.AddListener(OnLoadButtonClick);
            removeButton.onClick.AddListener(OnRemoveButtonClick);
            posButton.onClick.AddListener(OnPosButtonClick);
            linkField.onEndEdit.AddListener(OnEndEdit);
            this.videoSourcesPanel = videoSourcesPanel;
            this.videoSourceModel  = videoSourceModel;

            string videoPath = Application.persistentDataPath + "/Documents/video_" + videoSourceModel.id + ".mp4";

            if (File.Exists(videoPath))
            {
                statusText.text = "on disk";
            }
            else
            {
                statusText.text = "empty";
            }
        }
        public void OpenPosWindow(VideoSourceModel model)
        {
            Dictionary <string, VideoSourceModel> sources = sourceManager.GetAllVideoModels();

            camPosePanel.Init(model, sources.Count);
        }
 public void Dowload(VideoSourceModel model, IDownloadHandler downloadHandler)
 {
     downloadManager.Subscribe(downloadHandler);
     downloadManager.Download(new DownloadItem(model.id, model.path));
 }