Version: 2023.1
言語: 日本語
public static string gpuModuleIdentifier ;

説明

The identifier of the GPU Usage Profiler module.

Compare this constant to ProfilerWindow.selectedModuleIdentifier to check if the currently selected Profiler module is the CPU Usage Profiler module.

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