value | Profiler 窗口中当前选定帧的从零开始的索引。一个长整型。 |
当 Profiler 窗口的选定帧索引更改时,调用其调用列表中的方法。
Profiler 窗口的选定帧索引可能会因多种原因发生更改,例如捕获新帧、用户选择新帧或加载新的捕获。
using UnityEditor; using UnityEngine;
public class Example : EditorWindow { ProfilerWindow m_Profiler; long m_SelectedFrameIndex;
[MenuItem("Window/Analysis/Profiler Extension")] public static void ShowExampleWindow() { GetWindow<Example>(); }
void OnEnable() { // Make sure there is an open Profiler Window. if (m_Profiler == null) m_Profiler = EditorWindow.GetWindow<ProfilerWindow>();
// Subscribe to the Profiler window's SelectedFrameIndexChanged event. m_Profiler.SelectedFrameIndexChanged += OnProfilerSelectedFrameIndexChanged; }
private void OnGUI() { GUILayout.Label($"The selected frame in the Profiler window is {m_SelectedFrameIndex}."); }
private void OnDisable() { // Unsubscribe from the Profiler window's SelectedFrameIndexChanged event. m_Profiler.SelectedFrameIndexChanged -= OnProfilerSelectedFrameIndexChanged; }
void OnProfilerSelectedFrameIndexChanged(long selectedFrameIndex) { // Update the GUI with the selected Profiler frame. m_SelectedFrameIndex = selectedFrameIndex; Repaint(); } }