GetUnityObjectInfo
Gets the UnityEngine.Object information for a given Instance ID.
Read time 2 minutesLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEditor.Profiling
- Assembly: UnityEditor.CoreModule
GetUnityObjectInfo(EntityId, UnityObjectInfo)
Gets the UnityEngine.Object information for a given Instance ID.
public bool GetUnityObjectInfo(EntityId entityId, out FrameDataView.UnityObjectInfo info)
Parameters
UnityEngine.Object entity identifier.
UnityEngine.Object information output struct with name and other attributes.
Returns
Type | Description |
|---|---|
| bool | Returns true if entityId exists in the frame and object information is available. |
Remarks
Obtains information about the Object instance in the profiler capture.
The Profiler sample can be associated with an instance of an object instance that represents an Asset, a GameObject, or anything that is derived from Object.
This information is available as a part of sample metadata. To get this metadata you can use RawFrameDataView.GetSampleMetadataAsInt or HierarchyFrameDataView.GetItemEntityId.
using UnityEditorInternal;using UnityEditor.Profiling;using UnityEngine;public class Example{ public static string GetInstanceName(int frame, EntityId entityId) { using (var frameData = ProfilerDriver.GetRawFrameDataView(frame, 0)) { if (!frameData.GetUnityObjectInfo(entityId, out var info)) return "N/A"; return (frameData.GetUnityObjectNativeTypeInfo(info.nativeTypeIndex, out var typeInfo)) ? typeInfo.name + ": " + info.name : info.name; } }}
Additional Resources: RawFrameDataView.GetSampleMetadataAsInt, HierarchyFrameDataView.GetItemEntityId, Object.GetEntityId().
GetUnityObjectInfo(int, UnityObjectInfo)
Gets the UnityEngine.Object information for a given Instance ID.
public bool GetUnityObjectInfo(int instanceId, out FrameDataView.UnityObjectInfo info)
Parameters
UnityEngine.Object information output struct with name and other attributes.
Returns
Type | Description |
|---|---|
| bool | Returns true if entityId exists in the frame and object information is available. |
Remarks
Obtains information about the Object instance in the profiler capture.
The Profiler sample can be associated with an instance of an object instance that represents an Asset, a GameObject, or anything that is derived from Object.
This information is available as a part of sample metadata. To get this metadata you can use RawFrameDataView.GetSampleMetadataAsInt or HierarchyFrameDataView.GetItemEntityId.
using UnityEditorInternal;using UnityEditor.Profiling;using UnityEngine;public class Example{ public static string GetInstanceName(int frame, EntityId entityId) { using (var frameData = ProfilerDriver.GetRawFrameDataView(frame, 0)) { if (!frameData.GetUnityObjectInfo(entityId, out var info)) return "N/A"; return (frameData.GetUnityObjectNativeTypeInfo(info.nativeTypeIndex, out var typeInfo)) ? typeInfo.name + ": " + info.name : info.name; } }}
Additional Resources: RawFrameDataView.GetSampleMetadataAsInt, HierarchyFrameDataView.GetItemEntityId, Object.GetEntityId().