public void DrawAnnotationsOnTimeline() { GameObject annotationMarks = GameObject.Find("AnnotationMarks"); if (annotationMarks != null) { GameObject.Destroy(annotationMarks); } GameObject slider = GameObject.Find("Slider"); annotationMarks = new GameObject("AnnotationMarks"); annotationMarks.transform.SetParent(slider.transform); annotationMarks.transform.localPosition = Vector3.zero; annotationMarks.transform.localScale = Vector3.one; annotationMarks.transform.localRotation = Quaternion.identity; foreach (StaticAnnotation sa in staticAnnotationList) { float start = sa.getStart(); float width = slider.GetComponent <RectTransform>().rect.width; float ratio = start / _video.getVideoDuration(); float xposition = (ratio * width) - (width / 2); Sprite p = (Sprite)Resources.Load("Textures/Annotation", typeof(Sprite)); GameObject r = new GameObject("Annotation"); r.transform.SetParent(annotationMarks.transform); SpriteRenderer rend = r.AddComponent <SpriteRenderer>(); rend.sprite = p; r.transform.localRotation = Quaternion.identity; r.transform.localPosition = new Vector3(xposition, 0, 0); r.transform.localScale = Vector3.one; } }
void HandleVideoPlayback() { if (_leftController.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad) && _video != null) { Vector2 touchpad = _leftController.GetAxis(EVRButtonId.k_EButton_SteamVR_Touchpad); if (touchpad.y > 0.7f) { print("Pressed Stop"); _video.Stop(); _playing = false; _annotationManager.DisableAnnotations(); _annotationManager.currentTime = 0.0f; _annotationManager.IsPlayingVideo = false; GameObject o = GameObject.Find("Avatar"); if (o != null) { o.GetComponent <SkeletonRepresentation>().hide(); } } else if (touchpad.y < -0.7f) { print("Pressed Play"); _playing = !_playing; if (_playing) { _video.Play(); SetRepresentation(_representation); _annotationManager.IsPlayingVideo = true; } else { _video.Pause(); _annotationManager.IsPlayingVideo = false; } } else if (touchpad.x > 0.7f) { print("Pressed Foward"); _video.Skip5Sec(); } else if (touchpad.x < -0.7f) { print("Pressed Backward"); _video.Back5Sec(); } } if (_video != null && _video.getVideoTime() != 0 && _video.getVideoDuration() != 0) { float ratio = _video.getVideoTime() / _video.getVideoDuration(); //_slider.SetActive(true); _slider.GetComponentInChildren <Slider>().value = ratio; //_slider.transform.position = new Vector3(0, 2.5f, 0); // _slider.transform.forward = Camera.main.transform.forward; } if (_video != null) { _video.Update(); } }