Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

TransformLookup

struct in Unity.Entities

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

A [NativeContainer] that provides access to all instances of TransformRef components, indexed by Entity.

TransformLookup is a native container that provides array-like access to TransformRef components. For example, while iterating over a set of entities, you can use TransformLookup to get and set the transforms of unrelated entities.

To get a TransformLookup, call SystemState.GetTransformLookup.

Pass a TransformLookup container to a job by defining a public field of the appropriate type in your IJob implementation. You can safely read from TransformLookup in any job, but by default, you cannot write to components in the container in parallel jobs (including IJobEntity, SystemAPI.Query and IJobChunk). If you know that two instances of a parallel job can never write to the same index in the container, you can disable the restriction on parallel writing by adding [NativeDisableParallelForRestrictionAttribute] to the TransformLookup field definition in the job struct.

[NativeContainer]: https://docs.unity3d.com/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeContainerAttribute [NativeDisableParallelForRestrictionAttribute]: https://docs.unity3d.com/ScriptReference/Unity.Collections.NativeDisableParallelForRestrictionAttribute.html

Properties

Property Description
this[Entity] Gets the TransformRef instance for the specified entity.

Public Methods

Method Description
DidChange Reports whether any of TransformRef components in the chunk containing the specified Entity could have changed since a previous version.
EntityExists Reports whether the specified entity exists. Does not consider whether a TransformRef exists on the given entity.
HasTransform Reports whether the specified Entity instance still refers to a valid entity and that it has a transform component.
TryGetTransform Retrieves the transform components associated with the specified Entity, if it exists. The return value indicates whether the component was successfully retrieved.
Update When a TransformLookup is cached by a system across multiple system updates, calling this function inside the system's OnUpdate() method performs the minimal incremental updates necessary to make the lookup safe to use.