Version: 2023.1
LanguageEnglish
  • C#

ProfilerWindow.SelectedFrameIndexChanged

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Parameters

value The zero-based index of the frame currently selected in the Profiler Window. A long.

Description

Calls the methods in its invocation list when the Profiler window’s selected frame index changes.

The Profiler window’s selected frame index may change for a variety of reasons, such as a new frame being captured, the user selecting a new frame, or a new capture being loaded.

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(); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961