版本:Unity 6(6000.0)
语言英语
  • C#

ProfilerWindow.GetFrameTimeViewSampleSelectionController

建议修改

成功!

感谢您帮助我们提高 Unity 文档的质量。尽管我们不能接受所有提交,但我们确实会阅读用户建议的每个修改,并在适用的情况下进行更新。

关闭

提交失败

由于某些原因,无法提交您的建议修改。请在几分钟后<a>重试</a>。感谢您花时间帮助我们提高 Unity 文档的质量。

关闭

取消

声明

public Profiling.IProfilerFrameTimeViewSampleSelectionController GetFrameTimeViewSampleSelectionController(string moduleIdentifier);

参数

moduleIdentifier 您要检索其选择控制器的 Profiler 模块标识符。目前,只有 ProfilerWindow.cpuModuleIdentifierProfilerWindow.gpuModuleIdentifier 有效,其他选项将抛出 ArgumentException。

返回

IProfilerFrameTimeViewSampleSelectionController 一个 IProfilerFrameTimeViewSampleSelectionController 对象,您可以使用它来控制指定 Profiler 模块的选择。

描述

检索一个 IProfilerFrameTimeViewSampleSelectionController 对象,您可使用它来控制显示 Profiler 样品的计时信息(如 CPU 使用率模块GPU 使用率 Profiler 模块)的 Profiler 模块 中的选择。

using UnityEditor;
using UnityEditor.Profiling;
using UnityEngine;

public class Example : EditorWindow { ProfilerWindow m_Profiler = null; [MenuItem("Window/Analysis/Profiler Extension")] public static void ShowExampleWindow() { var window = GetWindow<Example>(); window.m_Profiler = EditorWindow.GetWindow<ProfilerWindow>(); }

void OnGUI() { // First make sure there is an open Profiler Window if (m_Profiler == null) m_Profiler = EditorWindow.GetWindow<ProfilerWindow>(); // If the currently selected Module is not the CPU Usage module, setting the selection will not be visible to the user immediately if (m_Profiler.selectedModuleIdentifier == ProfilerWindow.cpuModuleIdentifier) { // Get the CPU Usage Profiler module's selection controller interface to interact with the selection var cpuSampleSelectionController = m_Profiler.GetFrameTimeViewSampleSelectionController(ProfilerWindow.cpuModuleIdentifier); // If the current selection object is null, there is no selection to print out. using (new EditorGUI.DisabledScope(cpuSampleSelectionController.selection == null)) { if (GUILayout.Button("Print current Selection")) { // Get the currently shown selection and log out some of its details var selection = cpuSampleSelectionController.selection; Debug.Log($"The sample currently selected in the CPU Usage Profiler module is {selection.sampleDisplayName} at a depth of {selection.markerPathDepth}."); } } } } }