#Optional Components in IJE?

1 messages · Page 1 of 1 (latest)

agile python
#

Is it possible to tell IJE that a Component is optional, without using Aspects? I thought about using [WithAny], but then I can't use the OptionalComp c3 in the Execute()

private partial struct Job1 : IJobEntity
{
    private void Execute(MandatoryComp1 c1, MandatoryComp2 c2, OptionalComp c3)
    {
        // Do something with c1 & c2
        // If we have c3 then do something with it as well, if not no problem...
    }
}

Is there any performance cost for using the Optional Attribute for Aspects? It would be interesting if anyone knows, because I couldn't find any information on it

In case anyone is interested how to do it with Aspects:
https://forum.unity.com/threads/how-to-check-if-iaspect-has-an-optional-component.1389807/

steep barn
#

Nope, you'll need to use a dirty aspect trick or just write ijobchunk for when you have more complex logic

agile python
#

that's so unfortunate :/
I hate the fact that I need to create an Aspect that I will never use anywhere else

#

I hope this is on a todo list at Unity 😄

steep barn
#

I agree, just write it in ijc, join the enlightened 🙃

agile python
#

noooo IJE spoiled me too much 😆

sinful isle
#

and somewhat dirty

#

so I'd say aspect is cleaner

#

or just IJE

steep barn
#

Faster in ijc though

#

You can do optional per chunk

#

Even write it as a seperate path without any checks

sinful isle
#

allthough, not sure

steep barn
#

Well sure, if optional component is ienableable things get a bit more murky

sinful isle
#

curious if you can break vectorization by doing something like
private NativeArray<T> _values;
and switch it with fallback when chunk doesn't have it

#

to avoid breaking vectorization

#

but then

#

does it even worth it

#

yeah, too niche

steep barn
#

I just write seperate loops depending if component exists or not 🙈