cpuModuleName
Deprecated: Use ProfilerWindow.cpuModuleIdentifier instead. The name of the CPU Usage Profiler module.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Field
- Namespace: UnityEditor
- Assembly: UnityEditor
public const string cpuModuleName = "UnityEditorInternal.Profiling.CPUProfilerModule, UnityEditor.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
Remarks
Compare this constant to ProfilerWindow.selectedModuleName to check if the currently selected Profiler module is the CPU Usage Profiler module. Note: This text remains in English, even if the UI is translated into other languages.
Examples
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.selectedModuleName == ProfilerWindow.cpuModuleName) { // Get the CPU Usage Profiler module's selection controller interface to interact with the selection var cpuSampleSelectionController = m_Profiler.GetFrameTimeViewSampleSelectionController(ProfilerWindow.cpuModuleName); // 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 currently selected sample is {selection.sampleDisplayName} at a depth of {selection.markerPathDepth}."); } } } }}