2 types of Entity in my game Both have same IBufferElement B, Except one Enum field in B. I tried and successfully added that Generic IBufferElement into both said types.
Ok then the problem came, I made my first generic ISystem, red popup appeared when I tried to put that DynamicBuffer<B<TEnum>> into the query:
The type 'B<TEnum>' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'DynamicBuffer<T>'The type 'T' in DynamicBuffer<T>, UnityEngineComponent<T>, RefRO<T>, RefRW<T>, EnabledRefRO<T> and EnabledRefRW<T> must not contain a generic type parameter
After that, I searched over the internet to see how people Handle the generic component in the System (or Generic System), all I saw that they was using Generic Job, no one used foreach to query the Generic Component/Buffer.
Then why DynamicBuffer<T>, UnityEngineComponent<T>, RefRO<T>, ... in Query if generic component do exist?
More details of my case, Tool and Unit have B attached to them (only thing different is an Enum field in B), they both can be spawned through Structure, then their spawning process will be controlled by a set of systems (my case: 4 systems), the only system that need information of TEnum is IncSpawnCountSystem, which needs TEnum to look for the spawnCost.
Sorry for not posting the code here cause it is quite complicated
And Thanks for your supports