Esempio n. 1
0
 private void HandleNativeProfilerTimelineInput(Rect threadRect, int frameIndex, int threadIndex, float timeOffset, float topMargin)
 {
     if (threadRect.Contains(Event.current.mousePosition))
     {
         bool flag  = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown;
         bool flag2 = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown;
         bool flag3 = (flag || flag2) && Event.current.button == 0;
         if (flag3)
         {
             NativeProfilerTimeline_GetEntryAtPositionArgs nativeProfilerTimeline_GetEntryAtPositionArgs = default(NativeProfilerTimeline_GetEntryAtPositionArgs);
             nativeProfilerTimeline_GetEntryAtPositionArgs.Reset();
             nativeProfilerTimeline_GetEntryAtPositionArgs.frameIndex    = frameIndex;
             nativeProfilerTimeline_GetEntryAtPositionArgs.threadIndex   = threadIndex;
             nativeProfilerTimeline_GetEntryAtPositionArgs.timeOffset    = timeOffset;
             nativeProfilerTimeline_GetEntryAtPositionArgs.threadRect    = threadRect;
             nativeProfilerTimeline_GetEntryAtPositionArgs.shownAreaRect = this.m_TimeArea.shownArea;
             nativeProfilerTimeline_GetEntryAtPositionArgs.position      = Event.current.mousePosition;
             NativeProfilerTimeline.GetEntryAtPosition(ref nativeProfilerTimeline_GetEntryAtPositionArgs);
             int out_EntryIndex = nativeProfilerTimeline_GetEntryAtPositionArgs.out_EntryIndex;
             if (out_EntryIndex != -1)
             {
                 bool flag4 = !this.m_SelectedEntry.Equals(frameIndex, threadIndex, out_EntryIndex);
                 if (flag4)
                 {
                     NativeProfilerTimeline_GetEntryTimingInfoArgs nativeProfilerTimeline_GetEntryTimingInfoArgs = default(NativeProfilerTimeline_GetEntryTimingInfoArgs);
                     nativeProfilerTimeline_GetEntryTimingInfoArgs.Reset();
                     nativeProfilerTimeline_GetEntryTimingInfoArgs.frameIndex         = frameIndex;
                     nativeProfilerTimeline_GetEntryTimingInfoArgs.threadIndex        = threadIndex;
                     nativeProfilerTimeline_GetEntryTimingInfoArgs.entryIndex         = out_EntryIndex;
                     nativeProfilerTimeline_GetEntryTimingInfoArgs.calculateFrameData = true;
                     NativeProfilerTimeline.GetEntryTimingInfo(ref nativeProfilerTimeline_GetEntryTimingInfoArgs);
                     NativeProfilerTimeline_GetEntryInstanceInfoArgs nativeProfilerTimeline_GetEntryInstanceInfoArgs = default(NativeProfilerTimeline_GetEntryInstanceInfoArgs);
                     nativeProfilerTimeline_GetEntryInstanceInfoArgs.Reset();
                     nativeProfilerTimeline_GetEntryInstanceInfoArgs.frameIndex  = frameIndex;
                     nativeProfilerTimeline_GetEntryInstanceInfoArgs.threadIndex = threadIndex;
                     nativeProfilerTimeline_GetEntryInstanceInfoArgs.entryIndex  = out_EntryIndex;
                     NativeProfilerTimeline.GetEntryInstanceInfo(ref nativeProfilerTimeline_GetEntryInstanceInfoArgs);
                     this.m_Window.SetSelectedPropertyPath(nativeProfilerTimeline_GetEntryInstanceInfoArgs.out_Path);
                     this.m_SelectedEntry.Reset();
                     this.m_SelectedEntry.frameId       = frameIndex;
                     this.m_SelectedEntry.threadId      = threadIndex;
                     this.m_SelectedEntry.nativeIndex   = out_EntryIndex;
                     this.m_SelectedEntry.instanceId    = nativeProfilerTimeline_GetEntryInstanceInfoArgs.out_Id;
                     this.m_SelectedEntry.time          = nativeProfilerTimeline_GetEntryTimingInfoArgs.out_LocalStartTime;
                     this.m_SelectedEntry.duration      = nativeProfilerTimeline_GetEntryTimingInfoArgs.out_Duration;
                     this.m_SelectedEntry.totalDuration = nativeProfilerTimeline_GetEntryTimingInfoArgs.out_TotalDurationForFrame;
                     this.m_SelectedEntry.instanceCount = nativeProfilerTimeline_GetEntryTimingInfoArgs.out_InstanceCountForFrame;
                     this.m_SelectedEntry.relativeYPos  = nativeProfilerTimeline_GetEntryAtPositionArgs.out_EntryYMaxPos + topMargin;
                     this.m_SelectedEntry.name          = nativeProfilerTimeline_GetEntryAtPositionArgs.out_EntryName;
                     this.m_SelectedEntry.callstackInfo = nativeProfilerTimeline_GetEntryInstanceInfoArgs.out_CallstackInfo;
                     this.m_SelectedEntry.metaData      = nativeProfilerTimeline_GetEntryInstanceInfoArgs.out_MetaData;
                 }
                 Event.current.Use();
                 this.UpdateSelectedObject(flag, flag2);
             }
             else if (flag3)
             {
                 this.ClearSelection();
                 Event.current.Use();
             }
         }
     }
 }
Esempio n. 2
0
        void HandleNativeProfilerTimelineInput(Rect threadRect, int frameIndex, int threadIndex, float timeOffset, float topMargin)
        {
            // Only let this thread view change mouse state if it contained the mouse pos
            bool inThreadRect = threadRect.Contains(Event.current.mousePosition);

            if (!inThreadRect)
            {
                return;
            }

            bool singleClick = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown;
            bool doubleClick = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown;

            bool doSelect = (singleClick || doubleClick) && Event.current.button == 0;

            if (!doSelect)
            {
                return;
            }

            NativeProfilerTimeline_GetEntryAtPositionArgs posArgs = new NativeProfilerTimeline_GetEntryAtPositionArgs();

            posArgs.Reset();
            posArgs.frameIndex    = frameIndex;
            posArgs.threadIndex   = threadIndex;
            posArgs.timeOffset    = timeOffset;
            posArgs.threadRect    = threadRect;
            posArgs.shownAreaRect = m_TimeArea.shownArea;
            posArgs.position      = Event.current.mousePosition;

            NativeProfilerTimeline.GetEntryAtPosition(ref posArgs);

            int mouseOverIndex = posArgs.out_EntryIndex;

            if (mouseOverIndex != -1)
            {
                bool selectedChanged = !m_SelectedEntry.Equals(frameIndex, threadIndex, mouseOverIndex);
                if (selectedChanged)
                {
                    // Read out timing info
                    NativeProfilerTimeline_GetEntryTimingInfoArgs timingInfoArgs = new NativeProfilerTimeline_GetEntryTimingInfoArgs();
                    timingInfoArgs.Reset();
                    timingInfoArgs.frameIndex         = frameIndex;
                    timingInfoArgs.threadIndex        = threadIndex;
                    timingInfoArgs.entryIndex         = mouseOverIndex;
                    timingInfoArgs.calculateFrameData = true;
                    NativeProfilerTimeline.GetEntryTimingInfo(ref timingInfoArgs);

                    // Read out instance info for selection
                    NativeProfilerTimeline_GetEntryInstanceInfoArgs instanceInfoArgs = new NativeProfilerTimeline_GetEntryInstanceInfoArgs();
                    instanceInfoArgs.Reset();
                    instanceInfoArgs.frameIndex  = frameIndex;
                    instanceInfoArgs.threadIndex = threadIndex;
                    instanceInfoArgs.entryIndex  = mouseOverIndex;
                    NativeProfilerTimeline.GetEntryInstanceInfo(ref instanceInfoArgs);

                    m_Window.SetSelectedPropertyPath(instanceInfoArgs.out_Path);

                    // Set selected entry info
                    m_SelectedEntry.Reset();
                    m_SelectedEntry.frameId       = frameIndex;
                    m_SelectedEntry.threadId      = threadIndex;
                    m_SelectedEntry.nativeIndex   = mouseOverIndex;
                    m_SelectedEntry.instanceId    = instanceInfoArgs.out_Id;
                    m_SelectedEntry.time          = timingInfoArgs.out_LocalStartTime;
                    m_SelectedEntry.duration      = timingInfoArgs.out_Duration;
                    m_SelectedEntry.totalDuration = timingInfoArgs.out_TotalDurationForFrame;
                    m_SelectedEntry.instanceCount = timingInfoArgs.out_InstanceCountForFrame;
                    m_SelectedEntry.relativeYPos  = posArgs.out_EntryYMaxPos + topMargin;
                    m_SelectedEntry.name          = posArgs.out_EntryName;
                    m_SelectedEntry.callstackInfo = instanceInfoArgs.out_CallstackInfo;
                    m_SelectedEntry.metaData      = instanceInfoArgs.out_MetaData;
                }

                Event.current.Use();
                UpdateSelectedObject(singleClick, doubleClick);
            }
            else
            {
                // click on empty space de-selects
                if (doSelect)
                {
                    ClearSelection();
                    Event.current.Use();
                }
            }
        }