#EnabledRefRW vs SystemAPI.SetComponentEnabled

1 messages · Page 1 of 1 (latest)

pallid panther
#

As the title suggests, I find it unclear which one of these is the recommended way of toggling the enabled state of a component.

foreach (var (component, entity) in SystemAPI.Query<RefRW<Foo>>() .WithOptions(EntityQueryOptions.IgnoreComponentEnabledState) .WithEntityAccess()) { ... SystemAPI.SetComponentEnabled<Foo>(entity, true); }
or
foreach (var (component, componentEnabled) in SystemAPI.Query<RefRW<Foo>, EnabledRefRW<Foo>>() .WithOptions(EntityQueryOptions.IgnoreComponentEnabledState)) { ... componentEnabled.ValueRW = true; }

The latter seems the most intuitive, with the former looking to be mostly useful if another entity is to be updated.