Introduction to TransformHandle API
Introduction to the TransformHandle API and the key differences from the Transform API.
Read time 2 minutesLast updated 7 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.
TransformHandleTransformDifferences 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.
TransformHandleTransformTransform API (Unity 6.2 and earlier):
- You access the transform using the property.
GameObject.transform - The property returns a
transformcomponent reference (managed type).Transform - The API is managed and not compatible with the Burst compiler.
- The API works alongside API in Unity 6.
TransformHandle
TransformHandle API (Unity 6.3 and later):
- You access the transform using or
gameObject.transformHandle(wheretransform.GetTransformHandleis thetransformcomponent).Transform - Returns a struct (unmanaged type).
TransformHandle - Is compatible with the Burst compiler and can be used in Burst-compiled jobs.
- Ensures compatibility with future entity and GameObject interactions.
- TransformHandle API is runtime-only.
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)orTransformHandle h = transformHandle;h.parent = TransformHandle.None;
For specific examples on how to use the API, refer to TransfromHandle 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