All ComponentType must be known at compile time.

I’m currently getting this error.

System.ArgumentException : Unknown Type:CommonEcs.EcsHashMap2[System.UInt16,CommonEcs.ByteBool]` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].

I’ve encountered this error before and fixed it by creating an AssemblyInfo.cs file and add [assembly: RegisterGenericComponentType()] calls in it. I applied the same fix here and it no longer works. Now I’m confused how to fix this.

It’s maybe because I’m using it in another environment that the fix didn’t work. I’m trying to make my unit tests work so the code is running in test environment. There shouldn’t be any difference, but maybe there is.

Or it could be that AssemblyInfo is placed in the wrong folder. But I’ve tried everything. Tried it in the testing folder, then in the folder where EcsHashMap resides. Both cases don’t work.

What am I missing?

Nevermind. Used uint instead of ushort. :slight_smile:

Could you post the code that was causing the issue? Other people might benefit from it

Every time you use a generic struct or component like EcsHashMap<K, V>, the editor will throw out that error. The fix is to create a file named AssemblyInfo.cs in the same project/folder where such struct is used with the following content:

using Unity.Entities;

[assembly: RegisterGenericComponentType(typeof(EcsHashMap<ushort, ByteBool>))]
// You can specify more concrete types here
4 Likes

@davenirline Thank you for the tip! While I’m no longer getting errors, the inspector is now no longer showing any input fields where I can edit the contents (I am using ComponentDataProxy for this).

4965305--483215--upload_2019-9-15_13-52-36.png

The EntityDebugger shows the data correctly though (even if the naming is a bit wierd):
4965305--483212--upload_2019-9-15_13-52-21.png

Is that something you had to fix as well? Any hints would be appreciated :slight_smile:

Was it showing before? I don’t think fields are automatically rendered when using ComponentDataProxy.

Yes, they are. Every other ComponentProxy that I have has a neat little inspector.

Do you added Serializable?

@eizenhorn

Here’s the full source Code that I have and is not working as expected:

using Unity.Entities;

public interface ILight {}

[System.Serializable]
public struct ElementData<T> : IComponentData {
    public int units;
}

public class LightComponent : ComponentDataProxy<ElementData<ILight>> { }

plus the AssemblyInfo.cs file:

[assembly: RegisterGenericComponentType(typeof(ElementData<ILight>))]

(imports left out)

1 Like

I got this while running this piece of code, where {TYPE} was abstract

public class CustomObjectConversionSystem : GameObjectConversionSystem
{
    protected override void OnUpdate()
    {
        Entities.ForEach(({TYPE} input) =>
        { ... }
   }
}

FIX: do not use the abstract type