So, say you have IGeneric, a GenericStruct, and a GenericStruct2, both of which implement IGeneric. It’s possible to have a NativeArray but not NativeArray to hold both GenericStruct and GenericStruct2. Why? Is there any workaround? I tried using generics with type constraints but that still only lets me declare a list of either GenericStruct or GenericStruct2 which is functionally the same as just declaring a list of either of those types.
Is there some way to use generics in reverse? For instance, generics let you say “This containers (one) type MUST BE a struct and IGeneric” where I’d like to say “This container can only contain things that are type struct and generic.” if that makes sense…
I guess as an additional question: Is there ANY way to pass code into a job? I’ve tried lambdas, interfaces, actions… etc. Basically I want to be able to hand a job some code and have it run it. The closest I’ve gotten to getting it to work is interfaces, so that’s the focus of this post. If there’s a better way of doing things let me know.
Native containers can’t store interface because they reserves memory for each element and interface implementations can have different sizes. Moreover, it can’t be passed by value.