Exemplo n.º 1
0
        void DisplayOptions(TimelineWidget.DrawInfo drawInfo)
        {
            Rect backgroundRect = new Rect(drawInfo.layout.drawRect.x, drawInfo.timeline.drawRect.y, kOptionsRectWidth, drawInfo.timeline.drawRect.height);

            TimelineWidget.DrawRectangle(backgroundRect, kOptionsBackgroundColor);

            Rect rect = drawInfo.timeline.drawRect;

            rect.x      = drawInfo.layout.drawRect.x + kTextHorizontalMargin;
            rect.y     += kTextVerticalSpacing;
            rect.width  = kOptionsRectWidth;
            rect.height = kTextRectHeight;

            GUIStyle style = GUI.skin.toggle;

            style.normal.textColor = kTotalCostColor;
            m_bDisplayTotalCost    = GUI.Toggle(rect, m_bDisplayTotalCost, new GUIContent("Total cost"), style);
            rect.y += kTextVerticalSpacing;

            style.normal.textColor = kPoseCostColor;
            m_bDisplayPoseCost     = GUI.Toggle(rect, m_bDisplayPoseCost, new GUIContent("Pose cost"), style);
            rect.y += kTextVerticalSpacing;

            style.normal.textColor   = kTrajectoryCostColor;
            m_bDisplayTrajectoryCost = GUI.Toggle(rect, m_bDisplayTrajectoryCost, new GUIContent("Trajectory cost"), style);
        }
Exemplo n.º 2
0
 private void CreateUI()
 {
     _usertooltip = new Tooltip(this)
     {
         IsHidden = true
     };
     _loadingsprite = new LoadingSprite(this)
     {
         Positioner = (o) =>
         {
             return(new System.Drawing.Point(
                        Width - _loadingsprite.Width,
                        0));
         },
     };
     _loadingsprite.SetImage(GameResources.loading);
     _toolbar = new Toolbar(this, game.Track)
     {
         Y = 0
     };
     ZoomSlider    = new ZoomSlider(this, game.Track);
     _timeline     = new TimelineWidget(this, game.Track);
     _topcontainer = new Panel(this)
     {
         Height = 100,
         Dock   = Dock.Top,
         ShouldDrawBackground = false,
         MouseInputEnabled    = false,
     };
     _infobar      = new RightInfoBar(_topcontainer, game.Track);
     _trackinfobar = new TrackInfoBar(_topcontainer, game.Track);
 }
Exemplo n.º 3
0
        public void OnEnable()
        {
            m_DebuggerTimeline                = new TimelineWidget();
            m_CustomDrawers                   = new Dictionary <Type, ITimelineDebugDrawer>();
            m_SelectionProcessors             = new List <IFrameDebuggerSelectionProcessor>();
            m_RequestSelectProviderIdentifier = null;

            InitializeCustomDrawers();
            InitializeSelectionProcessors();

            Camera.onPostRender -= OnRender;
            Camera.onPostRender += OnRender;
        }
Exemplo n.º 4
0
    public void Draw(FrameDebugProviderInfo providerInfo, IFrameAggregate aggregate, TimelineWidget.DrawInfo drawInfo)
    {
        AbilityFrameAggregate abilityAggregate = (AbilityFrameAggregate)aggregate;

        foreach (AbilityState state in abilityAggregate.States)
        {
            float startPosition = drawInfo.GetPixelPosition(state.startTime);
            float endPosition   = drawInfo.GetPixelPosition(state.endTime);
            Rect  abilityRect   = new Rect(startPosition, drawInfo.timeline.drawRect.y, endPosition - startPosition, kAbilityRectHeight);

            TimelineWidget.DrawRectangleWithDetour(abilityRect, kAbilityWidgetBackgroundColor, kAbilityWidgetDetourColor);
            TimelineWidget.DrawLabelInsideRectangle(abilityRect, state.abilityType.FullName, kAbilityWidgetTextColor);
        }
    }
Exemplo n.º 5
0
        public void Init(Timeline timeline, PanManipulator panManipulator, ZoomManipulator zoomManipulator)
        {
            m_TimelineWidget = new TimelineWidget();

            m_PanManipulator  = panManipulator;
            m_ZoomManipulator = zoomManipulator;
            m_TimeArea        = timeline.m_TimelineScrollableArea;

            m_IMGUIContainer = new IMGUIContainer(() =>
            {
                GUILayout.Space(0);
                var lastRect = GUILayoutUtility.GetLastRect();
                Rect rt      = GUILayoutUtility.GetRect(lastRect.width, 22);

                GUI.BeginGroup(rt);

                Rect rect = new Rect(0, 0, rt.width, rt.height);

                if (rect.width > 0 && rect.height > 0)
                {
                    if (!FloatComparer.s_ComparerWithDefaultTolerance.Equals(m_DrawInfo.layout.startTime, m_TimelineWidget.RangeStart) ||
                        !FloatComparer.s_ComparerWithDefaultTolerance.Equals(m_DrawInfo.layout.Duration, m_TimelineWidget.RangeWidth))
                    {
                        m_DrawInfo.layout.startTime = m_TimelineWidget.RangeStart;
                        m_DrawInfo.layout.endTime   = m_TimelineWidget.RangeEnd;
                    }
                    else
                    {
                        DrawRuler(m_IMGUIContainer.layout, m_SampleRate, timeline.TimelineUnits);
                    }

                    ForwardEvents(rect);
                }

                GUI.EndGroup();
            });

            Add(m_IMGUIContainer);

            m_TickHandler = new TickHandler();
            float[] modulos =
            {
                0.0000001f, 0.0000005f, 0.000001f, 0.000005f, 0.00001f, 0.00005f, 0.0001f, 0.0005f,
                0.001f,         0.005f,     0.01f,     0.05f,     0.1f,     0.5f,       1,       5,10, 50, 100, 500,
                1000,             5000,     10000,     50000,   100000,   500000, 1000000, 5000000, 10000000
            };
            m_TickHandler.SetTickModulos(modulos);
        }
Exemplo n.º 6
0
        void DisplayYAxis(TimelineWidget.DrawInfo drawInfo)
        {
            float startX = math.max(drawInfo.layout.drawRect.x + kOptionsRectWidth, drawInfo.timeline.drawRect.x);

            Rect     maxVal = new Rect(startX + kAxisHorizontalTextOffset, drawInfo.timeline.drawRect.y, drawInfo.timeline.drawRect.width, kTextRectHeight);
            GUIStyle style  = new GUIStyle();

            style.normal.textColor = kAxisColor;

            GUI.Label(maxVal, new GUIContent($"{m_MaxCost:0.00}"), style);

            maxVal.y += drawInfo.timeline.drawRect.height - kTextRectHeight;
            GUI.Label(maxVal, new GUIContent("0"), style);


            TimelineWidget.DrawRectangle(new Rect(startX + kAxisHorizontalTextOffset * 0.5f, drawInfo.timeline.drawRect.y, 1.0f, drawInfo.timeline.drawRect.height), kAxisColor);
            TimelineWidget.DrawRectangle(new Rect(startX + kAxisHorizontalLineMargin, drawInfo.timeline.drawRect.y, kAxisHorizontalTextOffset - kAxisHorizontalLineMargin, 1.0f), kAxisColor);
            TimelineWidget.DrawRectangle(new Rect(startX + kAxisHorizontalLineMargin, drawInfo.timeline.drawRect.y + drawInfo.timeline.drawRect.height - 1, kAxisHorizontalTextOffset - kAxisHorizontalLineMargin, 1.0f), kAxisColor);
        }
        public void OnPostDraw()
        {
            if (m_SelectedAnimFrame.IsValid)
            {
                AnimationDebugRecord animStateRecord = Debugger.frameDebugger.FindAggregate <AnimationDebugRecord>(m_SelectedAnimFrame.providerIdentifier);
                if (animStateRecord == null)
                {
                    m_SelectedAnimFrame = AnimationFrameIdentifier.CreateInvalid();
                    return;
                }

                Assert.IsTrue(m_SelectedAnimFrame.animIndex < animStateRecord.AnimationRecords.Count);
                if (m_SelectedAnimFrame.animIndex >= animStateRecord.AnimationRecords.Count)
                {
                    m_SelectedAnimFrame = AnimationFrameIdentifier.CreateInvalid();
                    return;
                }

                AnimationRecord animRecord = animStateRecord.AnimationRecords[m_SelectedAnimFrame.animIndex];

                Assert.IsTrue(m_SelectedAnimFrame.animFrameIndex < animRecord.animFrames.Count);
                if (m_SelectedAnimFrame.animFrameIndex >= animRecord.animFrames.Count)
                {
                    m_SelectedAnimFrame = AnimationFrameIdentifier.CreateInvalid();
                    return;
                }

                AnimationFrameInfo animFrame = animRecord.animFrames[m_SelectedAnimFrame.animFrameIndex];

                string  label     = $"{animRecord.animName}\nFrame:{animFrame.animFrame:0.00}\nWeight:{animFrame.weight:0.00}";
                Vector2 labelSize = TimelineWidget.GetLabelSize(label);

                Rect toolTipRect = new Rect(Event.current.mousePosition.x + 20, Event.current.mousePosition.y, labelSize.x + 5.0f, labelSize.y + 5.0f);

                TimelineWidget.DrawRectangleWithDetour(toolTipRect, kTooltipBackgroundColor, kTooltipDetourColor);
                TimelineWidget.DrawLabel(toolTipRect, label, kTooltipTextColor);

                m_SelectedAnimFrame = AnimationFrameIdentifier.CreateInvalid();
            }
        }
        private void DrawAnimationWidget(FrameDebugProviderInfo providerInfo, AnimationDebugRecord animStateRecord, int animIndex, TimelineWidget.DrawInfo drawInfo)
        {
            AnimationRecord animation = animStateRecord.AnimationRecords[animIndex];

            if (animation.endTime < drawInfo.timeline.startTime)
            {
                return;
            }

            if (animation.startTime > drawInfo.timeline.endTime)
            {
                return;
            }

            float startPosition = drawInfo.GetPixelPosition(animation.startTime);
            float endPosition   = drawInfo.GetPixelPosition(animation.endTime);

            Rect drawRect = drawInfo.timeline.drawRect;

            drawRect.y += animation.rank * kAnimWidgetOffset;
            Rect animRect = new Rect(startPosition, drawRect.y, endPosition - startPosition, kAnimWidgetHeight);

            TimelineWidget.DrawRectangleWithDetour(animRect, kAnimWidgetBackgroundColor, kAnimWidgetDetourColor);

            int barStartPosition = Missing.truncToInt(startPosition) + 1;
            int maxBarPosition   = Missing.truncToInt(endPosition);

            for (int i = 0; i < animation.animFrames.Count; ++i)
            {
                int barEndPosition = Missing.truncToInt(drawInfo.GetPixelPosition(animation.animFrames[i].endTime));
                if (barEndPosition > barStartPosition)
                {
                    float weight = animation.animFrames[i].weight;
                    if (weight < 1.0f)
                    {
                        Rect barRect = new Rect(barStartPosition, drawRect.y, barEndPosition - barStartPosition, (1.0f - weight) * kAnimWidgetHeight);
                        TimelineWidget.DrawRectangle(barRect, kAnimWidgetWeightColor);
                    }
                }
                barStartPosition = barEndPosition;
            }

            TimelineWidget.DrawLabelInsideRectangle(animRect, animation.animName, kAnimWidgetTextColor);

            // check if mouse is hovering the anim widget
            if (endPosition > startPosition && animRect.Contains(Event.current.mousePosition))
            {
                float mouseNormalizedTime = (Event.current.mousePosition.x - startPosition) / (endPosition - startPosition);
                float mouseTime           = animation.startTime + mouseNormalizedTime * (animation.endTime - animation.startTime);

                float curStartTime = animation.startTime;
                for (int i = 0; i < animation.animFrames.Count; ++i)
                {
                    float curEndTime = animation.animFrames[i].endTime;
                    if (curStartTime <= mouseTime && mouseTime <= curEndTime)
                    {
                        m_SelectedAnimFrame.providerIdentifier = providerInfo.uniqueIdentifier;
                        m_SelectedAnimFrame.animIndex          = animIndex;
                        m_SelectedAnimFrame.animFrameIndex     = i;
                        m_SelectedAnimFrame.mouseX             = Missing.truncToInt(Event.current.mousePosition.x);
                        return;
                    }
                    curStartTime = curEndTime;
                }
            }
        }
Exemplo n.º 9
0
        void DrawDebuggerTimeline()
        {
            IEnumerable <FrameDebugProviderInfo> providers = Debugger.frameDebugger.NumSelected == 0 ? Debugger.frameDebugger.ProviderInfos : Debugger.frameDebugger.Selection.Select(p => p.providerInfo);

            var  lastRect = GUILayoutUtility.GetLastRect();
            Rect rt       = GUILayoutUtility.GetRect(lastRect.width, 54);

            List <float> timelineHeights = new List <float>();

            foreach (FrameDebugProviderInfo provider in providers)
            {
                timelineHeights.Add(kCharacterNameOffset);
                rt.height += kCharacterNameOffset;

                List <IFrameAggregate> frameAggregates = Debugger.frameDebugger.GetFrameAggregates(provider.uniqueIdentifier);
                foreach (IFrameAggregate frameAggregate in frameAggregates)
                {
                    float timelineHeight = m_CustomDrawers[frameAggregate.GetType()].GetDrawHeight(frameAggregate);
                    timelineHeights.Add(timelineHeight);
                    rt.height += timelineHeight;
                }
            }

            GUI.BeginGroup(rt);
            {
                Rect rect = new Rect(0, 0, rt.width, rt.height);

                if (m_BackgroundColor == Color.white)
                {
                    m_BackgroundColor = EditorGUIUtility.isProSkin ? new Color(0.12f, 0.12f, 0.12f, 0.78f) : new Color(0.66f, 0.66f, 0.66f, 0.78f);
                }

                GUI.color = m_BackgroundColor;
                GUI.DrawTexture(rect, EditorGUIUtility.whiteTexture);

                TimelineWidget.DrawInfo drawInfo = TimelineWidget.DrawInfo.Create(rect, m_DebuggerTimeline.RangeStart, m_DebuggerTimeline.RangeEnd, m_DebuggerTimeline.SelectedRangeStart, m_DebuggerTimeline.SelectedRangeEnd);
                drawInfo.layout = new TimelineWidget.DrawRangeInfo()
                {
                    drawRect  = rect,
                    startTime = m_DebuggerTimeline.RangeStart,
                    endTime   = m_DebuggerTimeline.RangeEnd
                };

                drawInfo.timeline.drawRect.y += kBeginOffset;

                int timelineIndex = 0;

                Color highlightColor = Debugger.instance.rewind ? new Color(0.0f, 0.25f, 0.5f, 0.1f) : new Color(0.8f, 0.0f, 0.0f, 0.2f);

                if (providers.Count() > 0)
                {
                    foreach (FrameDebugProviderInfo provider in providers)
                    {
                        List <IFrameAggregate> frameAggregates = Debugger.frameDebugger.GetFrameAggregates(provider.uniqueIdentifier);

                        // Display name
                        string displayName = provider.displayName;

                        drawInfo.timeline.drawRect.height = kCharacterNameRectangleHeight;

                        Vector2 labelSize       = TimelineWidget.GetLabelSize(displayName);
                        Rect    displayNameRect = drawInfo.timeline.drawRect;
                        displayNameRect.x     = drawInfo.layout.drawRect.x;
                        displayNameRect.width = drawInfo.layout.drawRect.width;
                        TimelineWidget.DrawRectangle(displayNameRect, new Color(0.1f, 0.1f, 0.1f, 1.0f));
                        TimelineWidget.DrawLabel(new Rect(displayNameRect.x + 10.0f, displayNameRect.y, labelSize.x, kCharacterNameRectangleHeight), displayName, Color.white);

                        drawInfo.timeline.drawRect.y += timelineHeights[timelineIndex++];

                        drawInfo.timeline.drawRect.height = 0.0f;

                        int providerTimelineIndex = timelineIndex;
                        foreach (IFrameAggregate frameAggregate in frameAggregates)
                        {
                            drawInfo.timeline.drawRect.height += timelineHeights[providerTimelineIndex++];
                        }

                        Rect highlightRect = new Rect(drawInfo.GetPixelPosition(m_DebuggerTimeline.SelectedRangeStart) - 2.0f,
                                                      drawInfo.timeline.drawRect.y - 2.0f,
                                                      drawInfo.GetPixelPosition(m_DebuggerTimeline.SelectedRangeEnd) - drawInfo.GetPixelPosition(m_DebuggerTimeline.SelectedRangeStart) + 4.0f,
                                                      drawInfo.timeline.drawRect.height + 2.0f);

                        TimelineWidget.DrawRange(highlightRect, highlightColor);

                        foreach (IFrameAggregate frameAggregate in frameAggregates)
                        {
                            float timelineHeight = timelineHeights[timelineIndex++];
                            drawInfo.timeline.drawRect.height = timelineHeight;

                            m_CustomDrawers[frameAggregate.GetType()].Draw(provider, frameAggregate, drawInfo);

                            drawInfo.timeline.drawRect.y += timelineHeight;
                        }


                        if (Debugger.instance.IsState(Debugger.State.Record))
                        {
                            TimelineWidget.DrawRectangleDetour(highlightRect, Color.red, 2.0f);
                        }
                    }
                }
                else
                {
                    Rect highlightRect = new Rect(drawInfo.GetPixelPosition(m_DebuggerTimeline.SelectedRangeStart) - 2.0f,
                                                  drawInfo.layout.drawRect.y,
                                                  drawInfo.GetPixelPosition(m_DebuggerTimeline.SelectedRangeEnd) - drawInfo.GetPixelPosition(m_DebuggerTimeline.SelectedRangeStart) + 4.0f,
                                                  drawInfo.layout.drawRect.height);

                    TimelineWidget.DrawRange(highlightRect, highlightColor);

                    if (Debugger.instance.IsState(Debugger.State.Record))
                    {
                        TimelineWidget.DrawRectangleDetour(highlightRect, Color.red, 2.0f);
                    }
                }

                TimelineWidget.DrawNotations(drawInfo);

                m_DebuggerTimeline.Update(rect, Debugger.instance.rewind ? -1.0f : Debugger.instance.time);

                var debugger = Debugger.instance;

                if (Application.isPlaying)
                {
                    Color cursorColor = new Color(0.5f, 0.5f, 0.0f, 1.0f);

                    TimelineWidget.DrawLineAtTime(
                        drawInfo, debugger.rewindTime,
                        cursorColor);
                }

                foreach (var drawer in m_CustomDrawers)
                {
                    drawer.Value.OnPostDraw();
                }

                if (debugger.isActive)
                {
                    if (rect.Contains(Event.current.mousePosition))
                    {
                        var e = Event.current;

                        if (e.button == 0 && !e.alt)
                        {
                            if (e.type == EventType.MouseDrag || e.type == EventType.MouseDown || e.type == EventType.MouseUp)
                            {
                                e.Use();

                                m_DebuggerTimeline.Repaint = true;
                                EditorGUIUtility.AddCursorRect(rect, MouseCursor.Arrow);

                                float currentTime =
                                    m_DebuggerTimeline.GetCurrentPositionFromMouse(
                                        rect, Event.current.mousePosition);

                                float start = m_DebuggerTimeline.SelectedRangeStart;
                                float end   = m_DebuggerTimeline.SelectedRangeEnd;

                                debugger.rewindTime = Mathf.Clamp(currentTime, start, end);

                                debugger.rewind = debugger.rewind || currentTime <= end;
                            }
                        }
                    }
                }

                GUI.EndGroup();
            }

            GUILayout.Space(5 + rt.height);
        }