Beispiel #1
0
        void HandleInputForChart(Rect expandRect)
        {
            int metricCount = m_TreeView.historyCurve.GetLuaRecordLength();

            if (metricCount == 0)
            {
                return;
            }

            bool isFrame = LuaDeepProfilerSetting.Instance.isFrameRecord;
            bool isEvent = false;
            bool isLeft  = false;
            bool isRight = false;

            if (Event.current.type == EventType.MouseDrag || Event.current.type == EventType.MouseUp)
            {
                Vector2 mousePosition = Event.current.mousePosition;
                if (mousePosition.x >= expandRect.xMin && mousePosition.x <= expandRect.xMax &&
                    mousePosition.y >= expandRect.yMin && mousePosition.y <= expandRect.yMax)
                {
                    currentFrameIndex          = (int)(metricCount * (mousePosition.x - expandRect.xMin) / (expandRect.xMax - expandRect.xMin));
                    GUIUtility.keyboardControl = 0;
                    isEvent        = true;
                    isTouchInChart = true;
                }
                else
                {
                    isTouchInChart = false;
                }
            }
            else if (isTouchInChart && Event.current.type == EventType.KeyDown)
            {
                if (Event.current.keyCode == KeyCode.RightArrow)
                {
                    isEvent = true;
                    isRight = true;
                }
                if (Event.current.keyCode == KeyCode.LeftArrow)
                {
                    isEvent = true;
                    isLeft  = true;
                }
            }
            if (isEvent)
            {
                if (isLeft)
                {
                    if (isFrame)
                    {
                        endFrame   = m_TreeView.GetPreFrame(startFrame, true);
                        startFrame = m_TreeView.GetPreFrame(endFrame, false);
                    }
                    else
                    {
                        startFrame--;
                    }
                }
                else if (isRight)
                {
                    if (isFrame)
                    {
                        startFrame = m_TreeView.GetNextFrame(endFrame, true);
                        endFrame   = m_TreeView.GetNextFrame(startFrame, false);
                    }
                    else
                    {
                        endFrame++;
                    }
                }
                else
                {
                    if (isFrame)
                    {
                        startFrame = m_TreeView.GetPreFrame(currentFrameIndex, false);
                        endFrame   = m_TreeView.GetNextFrame(currentFrameIndex, false);
                    }
                    else
                    {
                        startFrame = currentFrameIndex;
                        endFrame   = currentFrameIndex;
                    }
                }
                startFrame = Mathf.Min(Mathf.Max(0, startFrame), metricCount);
                endFrame   = Mathf.Min(Mathf.Max(0, endFrame), metricCount);

                m_TreeView.ReLoadSamples(startFrame, endFrame);
                int startGameFrame = m_TreeView.GetFrameCount(startFrame);
                int endGameFrame   = m_TreeView.GetFrameCount(endFrame);
                m_luaRefScrollView.LoadHistory(startGameFrame, endGameFrame);
            }

            Vector3 upPos   = PointFromRect(0, metricCount, startFrame, 0, 1, 0, expandRect);
            Vector3 downPos = PointFromRect(0, metricCount, startFrame, 0, 1, 1, expandRect);

            Handles.color = new Color(0.8f, 0.2f, 0.5f, 1f);
            CachedVec[0].Set(upPos.x, upPos.y, 0f);
            CachedVec[1].Set(downPos.x, downPos.y, 0f);
            Handles.DrawAAPolyLine(3.5f, CachedVec);

            upPos   = PointFromRect(0, metricCount, endFrame, 0, 1, 0, expandRect);
            downPos = PointFromRect(0, metricCount, endFrame, 0, 1, 1, expandRect);

            Handles.color = new Color(0.8f, 0.2f, 0.5f, 1f);
            CachedVec[0].Set(upPos.x, upPos.y, 0f);
            CachedVec[1].Set(downPos.x, downPos.y, 0f);
            Handles.DrawAAPolyLine(3.5f, CachedVec);
        }