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

EntityManager.SetComponentEnabled

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 void SetComponentEnabled(SystemHandle systemHandle, bool value);

Parameters

Parameter Description
systemHandle The system whose component should be enabled or disabled.
value True if the specified component should be enabled, or false if it should be disabled.

Description

Enable or disable a ComponentType on the specified SystemHandle.

This operation does not cause a structural change, and does not affect the current value of the component. To enable/disable components from a job, use ComponentLookup<T0>.SetComponentEnabled.

Additional resources: EntityManager.IsComponentEnabled, ComponentLookup<T0>.SetComponentEnabled


Declaration

public void SetComponentEnabled(Entity entity, bool value);

Parameters

Parameter Description
entity The entity whose component should be enabled or disabled.
value True if the specified component should be enabled, or false if it should be disabled.

Description

Enable or disable a ComponentType on the specified Entity.

This operation does not cause a structural change, and does not affect the current value of the component.

An entity with a disabled component will not match an EntityQuery that requires that component, and will match a query that excludes that component.

To enable/disable components from a job, use ComponentLookup<T0>.SetComponentEnabled. To enable/disable an entire Entity, use EntityManager.SetEnabled (which, unlike this function, does involve a structural change).

Additional resources: EntityManager.IsComponentEnabled, ComponentLookup<T0>.SetComponentEnabled


Declaration

public void SetComponentEnabled(EntityQuery query, bool value);

Parameters

Parameter Description
query The query whose matching chunks should be affected.
value If true, the component T will be enabled on all entities in all matching chunks. Otherwise, the component will be disabled on all entities in all matching chunks.

Description

Sets or clears the "is enabled" bit for the provided component on all entities in all chunks matched by the query, ignoring the current state of any enableable components in the query.

This method ignores the current state of all enableable components in the query. The target component will be enabled or disabled on every entity in every chunk that matches the query. Specifically, this function will enable disabled components on entities, even if the disabled component would cause its entity to not match the query.

To enable or disable a component on all entities that match a query (while respecting the current status of enableable components), the recommended workaround is to use a simple IJobEntity or foreach loop.

If any jobs are currently running which read or write the target component, this function will block until they complete before performing the requested operation.

Additional resources: EntityManager.IsComponentEnabled, ComponentLookup<T0>.SetComponentEnabled


Declaration

public void SetComponentEnabled(EntityQuery query, ComponentType componentType, bool value);

Parameters

Parameter Description
componentType The component type which should be enabled or disabled on all matching chunks. This type must be included in the query's required types, and must implement IEnableableComponent.
query The query whose matching chunks should be affected.
value If true, the component T will be enabled on all entities in all matching chunks. Otherwise, the component will be disabled on all entities in all matching chunks.

Description

Sets or clears the "is enabled" bit for the provided component on all entities in all chunks matched by the query, ignoring the current state of any enableable components in the query.

This method ignores the current state of all enableable components in the query. The target component will be enabled or disabled on every entity in every chunk that matches the query. Specifically, this function will enable disabled components on entities, even if the disabled component would cause its entity to not match the query.

To enable or disable a component on all entities that match a query (while respecting the current status of enableable components), the recommended workaround is to use a simple IJobEntity or foreach loop.

If any jobs are currently running which read or write the target component, this function will block until they complete before performing the requested operation.

Additional resources: EntityManager.IsComponentEnabled, ComponentLookup<T0>.SetComponentEnabled


Declaration

public void SetComponentEnabled(Entity entity, ComponentType componentType, bool value);

Parameters

Parameter Description
entity The entity whose component should be enabled or disabled.
componentType The component type to enable or disable. This type must implement the IEnableableComponent interface.
value True if the specified component should be enabled, or false if it should be disabled.

Description

Enable or disable ComponentType on the specified Entity.

This operation does not cause a structural change, and does not affect the current value of the component.

An entity with a disabled component will not match an EntityQuery that requires that component, and will match a query that excludes that component.

To enable/disable components from a job, use ComponentLookup<T0>.SetComponentEnabled. To enable/disable an entire Entity, use EntityManager.SetEnabled (which, unlike this function, does involve a structural change).

Additional resources: EntityManager.IsComponentEnabled, ComponentLookup<T0>.SetComponentEnabled