Exemple #1
0
        private void InitPreviewTimeline(MVideoClip clip, VisualElement element)
        {
            var previewTimeline = element.Q <VisualElement>(null, "KeyFrameDraggerElement");

            previewTimeline.RegisterCallback <MouseDownEvent>((MouseDownEvent evt) => {
                ToggleTimeline(clip.ID, true);
            });
            element.RegisterCallback <MouseMoveEvent>((MouseMoveEvent evt) => {
                if (IsTimelineActive(clip.ID))
                {
                    float time = (evt.localMousePosition.x / previewTimeline.contentRect.width);

                    this.ATVPivot.position = clip.GetPosition(time);
                    this.ATVPivot.forward  = clip.GetForward(time);

                    this.keyFrameManager.UpdateSceneViewCameraTransform(this.ATVPivot);
                    this.keyFrameManager.UpdateMainCameraTransform(clip.GetPosition(time), clip.GetForward(time));
                }
            });
            element.RegisterCallback <MouseUpEvent>((MouseUpEvent evt) => {
                ToggleTimeline(clip.ID, false);
            });

            /*element.RegisterCallback<MouseOutEvent>((MouseOutEvent evt) => {
             *  Debug.Log("MouseOut");
             *  ToggleTimeline(clip.ID, false);
             * },TrickleDown.TrickleDown);
             */
        }
Exemple #2
0
        private void Update()
        {
            if (IsPlaying)
            {
                elapsedTime      += Time.deltaTime;
                currentPercentage = elapsedTime / currentClip.Duration;

                this.ApplyClip(currentClip.GetPosition(currentPercentage), currentClip.GetForward(currentPercentage));

                if (currentClip.LeftTransition.Type != MTransition.TransitionType.none)
                {
                    if (elapsedTime < currentClip.LeftTransition.duration && !transitionsPlayer.isPlaying)
                    {
                        transitionsPlayer.PlayTransition(currentClip, currentVideoClipIndex, currentClip.LeftTransition);
                    }
                }

                if (currentClip.RightTransition.Type != MTransition.TransitionType.none)
                {
                    if (currentClip.Duration - elapsedTime > 0)
                    {
                        //Debug.Log((currentClip.Duration - elapsedTime) + " - " + currentClip.RightTransition.duration);
                        if (currentClip.Duration - elapsedTime <= currentClip.RightTransition.duration && !transitionsPlayer.isPlaying)
                        {
                            transitionsPlayer.PlayTransition(currentClip, currentVideoClipIndex, currentClip.RightTransition);
                        }
                    }
                }

                if (currentPercentage >= 1f)
                {
                    if (this.ForcedClipIndex != -1)
                    {
                        StartCoroutine(this.Stop());
                    }
                    else
                    {
                        currentVideoClipIndex++;
                        if (currentVideoClipIndex < mProject.clips.Count)
                        {
                            this.StartClip(currentVideoClipIndex);
                        }
                        else
                        {
                            StartCoroutine(this.Stop());
                        }
                    }
                }

                if (transitionsPlayer != null)
                {
                    transitionsPlayer.ManagedUpdate();
                }
                if (OnUpdate != null)
                {
                    OnUpdate(this.currentClip, elapsedTime, currentPercentage);
                }
            }
        }