public TimelineElement(RefreshScheduler scheduler, VisualElement extraViewer) { name = "timeline"; var timeArea = new VisualElement(); timeArea.name = "timeArea"; Add(timeArea); var timeAreaGUI = new TimeAreaGUI(); var imguiContainer = new IMGUIContainer(() => { timeAreaGUI.OnGUI(timeArea.layout); }); imguiContainer.name = "timeAreaGUI"; timeArea.Add(imguiContainer); imguiContainer.StretchToParentSize(); var timeProvider = new TimeConverter(timeAreaGUI); var playhead = new PlayheadElement(timeProvider); playhead.name = "playhead"; Add(playhead); imguiContainer.AddManipulator(new PlayheadDragManipulator(playhead)); playhead.AddManipulator(new PlayheadDragManipulator(playhead)); imguiContainer.AddManipulator(new TimeAreaCallbackManipulator(timeAreaGUI, playhead)); imguiContainer.AddManipulator(new TimeAreaResizeManipulator(playhead)); var trackContainer = new TrackContainer(timeProvider, scheduler, extraViewer); Add(trackContainer); //playhead needs to be on top of the tracks playhead.BringToFront(); scheduler.Refresh += () => { if (!GameDebuggerRecorder.isPlaying) { return; } var frame = GameDebuggerRecorder.currentFrame; var time = GameDebuggerDatabase.GetRecords(frame).time; playhead.SetTime(time); }; }
private void InitPreview() { m_ScrollViewContainer = m_RootElement.Q <VisualElement>("scrollview-container"); m_ScrollViewContainer.RegisterCallback <WheelEvent>(OnScrollWheel, TrickleDown.TrickleDown); m_ScrollViewContainer.RegisterCallback <GeometryChangedEvent>(OnGeometryChanged); m_ScrollView = m_RootElement.Q <ScrollView>("preview-scroll-view"); m_PreviewRenderer = m_RootElement.Q <IMGUIContainer>("preview-imgui-renderer"); m_PreviewRenderer.onGUIHandler = OnIMGUIRendered; m_PreviewRenderer.AddManipulator(m_TouchEventManipulator = new TouchEventManipulator(m_InputProvider)); }