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

SystemAPI.TryGetComponent

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

Declaration

public static bool TryGetComponent(Entity entity, out T result);

Parameters

Parameter Description
entity The entity.
result A struct of type T containing the component value, or default if the entity does not have the component.

Returns

bool True if the entity has the component, false otherwise.

Description

Try to look up the value of a component for an entity.

Use this method to look up data in another entity using its Entity object. For example, if you have a component that contains an Entity field, you can look up the component data for the referenced entity using this method.

Not working in Entities.ForEach, IJobEntity, and Utility methods