示例#1
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);
        }
    }
        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;
                }
            }
        }