Created
December 21, 2022 10:34
-
-
Save wotakuro/888a6bec9e28c4b9b9078e9dac84067d to your computer and use it in GitHub Desktop.
Unity ObjectRegister.WatchSample( Unity 2022 +)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditorInternal; | |
using UnityEditor.Profiling; | |
using UnityEditor; | |
public class ObjectRegisterWatchExample | |
{ | |
[MenuItem("Tools/ExecuteTest")] | |
public static void Execute() | |
{ | |
int objRegistmaker = FrameDataView.invalidMarkerId; | |
for (int i = ProfilerDriver.firstFrameIndex; i < ProfilerDriver.lastFrameIndex; ++i) | |
{ | |
using (var frameData = ProfilerDriver.GetRawFrameDataView(i, 0)) | |
{ | |
if (objRegistmaker == FrameDataView.invalidMarkerId) | |
{ | |
objRegistmaker = frameData.GetMarkerId("Object.Register"); | |
if (objRegistmaker == FrameDataView.invalidMarkerId) | |
break; | |
} | |
for (int j = 0; j < frameData.sampleCount; ++j) | |
{ | |
if( frameData.GetSampleMarkerId(j) == objRegistmaker) | |
{ | |
var instanceId = frameData.GetSampleMetadataAsInt(j, 0); | |
if (frameData.GetUnityObjectInfo(instanceId, out var objectInfo)) | |
{ | |
if( frameData.GetUnityObjectNativeTypeInfo(objectInfo.nativeTypeIndex, out var typeInfo) ){ | |
UnityEngine.Debug.Log("frame:"+ i +" "+ typeInfo.name + "::" + objectInfo.name); | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment