Hello everyone,
I’ve been experiencing a persistent issue with generic components in Unity’s ECS/NetCode. I’m attempting to use generic RPC components (specifically, using RpcCommandRequest<SyncDataRpc, SyncDataRpc>) in an entity query, but Unity’s type manager complains that the type is unknown at compile time.
Exception:
ArgumentException: Unknown Type:`Unity.NetCode.RpcCommandRequest`2[SyncDataRpc,SyncDataRpcc]` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].
RPC Type:
[BurstCompile]
public struct SyncDataRpc: IComponentData, IRpcCommandSerializer<SyncDataRpc>
{
public int Data;
// Serialize, Deserialize, CompileExecute implementations...
}
Generic Registration:
using Unity.Entities;
using Unity.NetCode;
[assembly: RegisterGenericComponentType(typeof(RpcCommandRequest<SyncDataRpc, SyncDataRpc>))]
Query:
var builder = new EntityQueryBuilder(Allocator.Temp)
.WithAny<RpcCommandRequest<SyncDataRpc, SyncDataRpc>>();
m_RPCsQuery = state.GetEntityQuery(builder);
Has anyone encountered similar issues with generic component registration and entity queries? Are there additional workarounds or known package bugs that might be causing this behavior? Any help or insight would be greatly appreciated.
Thanks in advance!