#[1.0.0-pre.65] Compiler error when trying to get both EnabledRefXX and RefXX in the same IJobEntity

1 messages · Page 1 of 1 (latest)

tight lion
#

1.0.0-pre.44 changelog says:

Using EnabledRefXX<T> and RefXX<T> wrappers on the same component in the same IJobEntity.Execute() method no longer throws compiler errors.

But 1.0.0-pre.65 throws this error:

error SGJE0017: SetEnableableComponentJob has duplicate components of same type MyEnableableComponent. Remove all but one to fix.

Here is a snippet to reproduce this case:

public partial struct MyEnableableComponent : IComponentData, IEnableableComponent
{
    public int value;
}

[BurstCompile]
public partial struct SetEnableableComponentJob : IJobEntity
{
    public void Execute(
          EnabledRefRW<MyEnableableComponent> enabledRefRW
        , RefRW<MyEnableableComponent> refRW
    )
    {
        enabledRefRW.ValueRW = true;
        refRW.ValueRW.value = 5;
    }
}
#

[1.0.0-pre.65] Compiler error when trying to get both EnabledRefXX and RefXX in the same IJobEntity

haughty oasis
#

I believe the workaround atm is to create an aspect

tight lion
#

Adding an aspect and this error is thrown as soon as I enter play mode 😂

ArgumentException: Unknown Type:MyEnableableComponentAspect All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].

haughty oasis
#

what does the aspect look like?

tight lion
# haughty oasis what does the aspect look like?

Pretty simple like this:

public readonly partial struct MyEnableableAspect : IAspect
{
    private readonly RefRW<MyEnableableComponent> _refRW;
    private readonly EnabledRefRW<MyEnableableComponent> _enabledRefRW;

    public readonly Entity Entity;

    public bool Enabled
    {
        get => _enabledRefRW.ValueRO;
        set => _enabledRefRW.ValueRW = value;
    }

    public int Value
    {
        get => _refRW.ValueRO.value;
        set => _refRW.ValueRW.value = value;
    }
}
haughty oasis
#

that's odd

tight lion
#

This is the full code

#

My current workaround is breaking down the enableable component into a normal component and an enableable tag

haughty oasis
#

.WithAllRW<MyEnableableAspect>()

#

is your issue

#

it should be WithAspect

tight lion
#

Aspect doesn't work when the component is disabled 😓

haughty oasis
#

Hmmm

#

Would need a custom query probably