Introduction to TransformHandle API
Introduction to the TransformHandle API and the key differences from the Transform API.
Read time 2 minutesLast updated 12 days ago
The API is an alternative to the API. Unlike the component (a managed class), is an unmanaged , which makes it fully compatible with the Burst compiler.
TransformHandleTransformTransformTransformHandlestructWhile the API covers the same core operations as the API, its design introduces several key differences described on this page. The API ensures compatibility with future entity and GameObject interactions.
TransformHandleTransformTransformHandleDifferences with Transform API
The API functionality is equivalent to the API, the key differences are in the way you access it, and in the implementation details. The API works alongside the API in Unity 6.
TransformHandleTransformTransformHandleTransformTransform API (Unity 6.2 and earlier) | TransformHandle API (Unity 6.3 and later) |
|---|---|
You access the transform using the | You access the transform using |
Returns a | Returns a |
| The API is managed and not compatible with the Burst compiler. | Is compatible with the Burst compiler and can be used in Burst-compiled jobs. For more information, refer to the Using TransformHandle with Burst section. |
| Editor and runtime API. | Runtime-only API. |
Transform APIs that are not available in the TransformHandle API
The following methods and properties from APIs are not available in API:
TransformTransformHandle- /
GetSiblingIndexSetSiblingIndex Find- property
hasChanged
TransformHandle API without an equivalent in the Transform API
The following API elements don't have an equivalent in the API.
TransformHandleTransform-
represents an enumerable of the direct children of a transformHandle, and this enumerable returns a DirectChildrenEnumerator when enumerated.
TransformHandle.DirectChildrenEnumerable -
is an enumerator that goes through the direct children of a transform.
TransformHandle.DirectChildrenEnumerator -
returns a DirectChildrenEnumerable of this transform, which you can use to iterate over direct children with a foreach loop.
TransformHandle.DirectChildren -
returns a DirectChildrenEnumerator of this transform, which you can use to manually iterate over direct children.
TransformHandle.GetDirectChildrenEnumerator
Differences in common operations
The following common operations have a different implementation in API.
TransformHandleCheck if a transform is valid:
- Transform:
transform != null - TransformHandle:
TransformHandle.IsValid
Iterate the direct children of the transform:
- Transform:
foreach (Transform t in transform) - TransformHandle:
foreach (TransformHandle t in handle.DirectChildren)
Set a parent of a transform to :
None-
Transform:
transform.SetParent(null) -
TransformHandle:
transformHandle.SetParent(TransformHandle.None)Alternative declaration:TransformHandle h = transformHandle; h.parent = TransformHandle.None;
For specific examples on how to use the API, refer to TransformHandle API examples.
Methods with different argument or return types
The following methods are functionally equivalent, but have different argument types or return types (, or depending on the API they are called from).
TransformTransformHandleDifferent argument types:
IsChildOfLookAtSetParent- (overload)
Translate
Different return types:
GetChildparentroot