예제 #1
0
        public void OnEnable()
        {
            var root = this.GetRootVisualContainer();

            m_Scheduler = new RefreshScheduler(root);
            root.AddStyleSheetPath("Replay/Stylesheets/Styles");

            var debuggerView = new VisualElement();
            var extraViewer  = new VisualElement();

            debuggerView.name = "debuggerView";

            extraViewer.name        = "extraViewer";
            debuggerView.style.flex = 1;

            var header          = new HeaderElement(m_State);
            var timelineElement = new TimelineElement(m_Scheduler, extraViewer);

            debuggerView.Add(header);
            debuggerView.Add(timelineElement);

            root.Add(debuggerView);

            root.Add(extraViewer);
            root.style.flexDirection = FlexDirection.Row;
        }
        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);
            };
        }
예제 #3
0
        public TrackContainer(ITimeConverter timeConverter, RefreshScheduler scheduler, VisualElement extraViewer)
        {
            m_TimeConverter = timeConverter;
            m_ExtraViwer    = extraViewer;

            var trackTemplate = Resources.Load <VisualTreeAsset>("Replay/GameDebuggerTrackTemplate");

            m_ListView = new ListView(new List <int>(), 50, () => CreateTrack(trackTemplate), DrawItem);
            m_ListView.selectionType = SelectionType.None;
            Add(m_ListView);

            scheduler.ExitPlayMode += () =>
            {
                m_ListView.itemsSource = null;
                m_ListView.Refresh();
            };
            scheduler.Refresh += RefreshTracks;
            GameDebuggerDatabase.GameDebugerDatabaseLoaded += () => { RefreshTracks(true); };
        }