public readonly partial struct EffectActiveChangedAspect : IAspect
{
private readonly RefRO<EffectActive> effectActive;
}
[BurstCompile]
[WithChangeFilter(typeof(EffectActive))]
private partial struct ToggleTagsJob : IJobEntity
{
private void Execute(in DynamicBuffer<EffectTag> effectTag, EffectActiveChangedAspect effectActiveChanged)
{
// Executes every frame even though EffectActive not changed
}
}```
if I change it to manually use a query with a change filter, it no longer executes every frame
```cs
this.query = SystemAPI.QueryBuilder().WithAll<EffectActive, EffectTag>().Build();
this.query.SetChangedVersionFilter(ComponentType.ReadOnly<EffectActive>());```
#[WithChangeFilter] and IJobEntity don't work when there is an aspect
1 messages · Page 1 of 1 (latest)
original
manually specifying query
looking at source gen
void __AssignQueries(ref global::Unity.Entities.SystemState state)
{
DefaultQuery = new Unity.Entities.EntityQueryBuilder(Unity.Collections.Allocator.Temp)
.WithAll<global::BovineLabs.Effects.Data.Actions.EffectTag>()
.WithAll<global::BovineLabs.Effects.Data.EffectActive>()
.WithAspect<global::BovineLabs.Effects.Aspects.EffectActiveChangedAspect>()
.Build(ref state);
}```
it just completely ignores the changefilter
if I remove the aspect and just use the underlying component
void __AssignQueries(ref global::Unity.Entities.SystemState state)
{
DefaultQuery = state.GetEntityQuery
(
new Unity.Entities.EntityQueryDesc
{
All = new Unity.Entities.ComponentType[] {Unity.Entities.ComponentType.ReadOnly<global::BovineLabs.Effects.Data.Actions.EffectTag>(),
Unity.Entities.ComponentType.ReadWrite<global::BovineLabs.Effects.Data.EffectActive>()},
Any = new Unity.Entities.ComponentType[] {
},
None = new Unity.Entities.ComponentType[] {
},
Disabled = new Unity.Entities.ComponentType[] {
},
Absent = new Unity.Entities.ComponentType[] {
},
Options =
Unity.Entities.EntityQueryOptions.Default
}
);DefaultQuery.SetChangedVersionFilter(new ComponentType[1]
{
Unity.Entities.ComponentType.ReadOnly<global::BovineLabs.Effects.Data.EffectActive>()
});
}```
it now applies the changefilter correctly
@ember comet maybe (or at least you might know who!)
(i find it interesting one uses EntityQueryBuilder, the other doesn't)
Ugh! Thx for reporting it, and yeah I'm sadly aware of the descriprency between how SourceGen builds queries, tho I wasn't aware of any bugs, we'll look into it 😅
@ember comet
another broken case
[WithChangeFilter(typeof(AbilityOnCooldown))]
[WithDisabled(typeof(AbilityOnCooldown))]
private partial struct AbilityDeactivateJob : IJobEntity```
EntityQueryDescValidationException: EntityQuery contains a filter with duplicate component type name AbilityOnCooldown. Queries can only contain a single component of a given type in a filter.
and just to confirm, it does work fine when using a query builder instead
this.query = SystemAPI.QueryBuilder().WithAll<AbilityActive>().WithDisabled<AbilityOnCooldown>().Build();
this.query.AddChangedVersionFilter(ComponentType.ReadOnly<AbilityOnCooldown>());```
Oh no 😆
is there any issue tracker for this bug?
Dani on holidays (i think)
I can add
foreach (var animation in SystemAPI
.Query<RefRW<JellyAnimation>>()
.WithNone<IsAnimated>()
.WithChangeFilter<IsAnimated>()
)
{
animation.ValueRW.currentAnimationTime = 0;
}```
as another broken case
not sure you can work around the Query version
IJE can be worked around by just passing in your own query though
as for now I just used IsAnimated state in a if
there are like 5 entities at most which will trigger this so I assumed I could optimize scheduling cost away
personally i've never really found a case where a sync point is faster than schedule
maybe if you have a whole bunch of them
you could use ije.run i guess as an alternate workaround
is this query passed into schedule method?
this is the auto generated query
which is what is broken in IJE/and your Query case
WithChangeFilter is also adding the component to WithAll<>
even if it was added elsewhere (i.e. WithNone)
I meant the bottom part
ok, then I try this