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

ProfilerWindow.gpuModuleIdentifier

建议更改

成功!

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

关闭

提交失败

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

关闭

取消

public static string gpuModuleIdentifier;

说明

GPU 使用率分析模块 的标识符。

将此常量与 ProfilerWindow.selectedModuleIdentifier 进行比较,以检查当前选择的 分析模块 是否是 CPU 使用率分析器模块

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 GPU Usage module, setting the selection will not be visible to the user immediately if (m_Profiler.selectedModuleIdentifier == ProfilerWindow.gpuModuleIdentifier) { // Get the GPU Usage Profiler module's selection controller interface to interact with the selection var gpuSampleSelectionController = m_Profiler.GetFrameTimeViewSampleSelectionController(ProfilerWindow.gpuModuleIdentifier); // If the current selection object is null, there is no selection to print out. using (new EditorGUI.DisabledScope(gpuSampleSelectionController.selection != null)) { if (GUILayout.Button("Print current Selection")) { // Get the currently shown selection and log out some of its details var selection = gpuSampleSelectionController.selection; Debug.Log($"The sample currently selected in the GPU Usage Profiler module is {selection.sampleDisplayName} at a depth of {selection.markerPathDepth}."); } } } } }