Tons of [RegisterGenericComponentType] error on preview 33

I just upgraded and got these errors from Unity’s built-in types throwing repeatedly. Anyone with the same issue?

The RequestSceneLoaded one for example :

ArgumentException: Unknown Type:`Unity.Entities.RequestSceneLoaded` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].
Unity.Entities.TypeManager.GetTypeIndex (System.Type type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Types/TypeManager.cs:825)
Unity.Entities.TypeManager.GetTypeIndex[T] () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Types/TypeManager.cs:812)
Unity.Entities.ComponentType.ReadWrite[T] () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Types/ComponentType.cs:44)
Unity.Scenes.SubSceneStreamingSystem.OnCreate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Scenes.Hybrid/SubSceneStreamingSystem.cs:68)
Unity.Entities.ComponentSystemBase.CreateInstance (Unity.Entities.World world) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystem.cs:201)
Unity.Entities.World.AddSystem[T] (T system) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/World.cs:341)
Unity.Entities.World.CreateSystemInternal (System.Type type, System.Object[] constructorArguments) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/World.cs:235)
Unity.Entities.World.GetOrCreateSystemInternal (System.Type type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/World.cs:251)
Unity.Entities.World.GetOrCreateSystem (System.Type type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/World.cs:279)
Unity.Entities.DefaultWorldInitialization.GetOrCreateManagerAndLogException (Unity.Entities.World world, System.Type type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:38)
UnityEngine.Debug:LogException(Exception)
Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Stubs/Unity/Debug.cs:25)
Unity.Entities.DefaultWorldInitialization:GetOrCreateManagerAndLogException(World, Type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:42)
Unity.Entities.DefaultWorldInitialization:Initialize(String, Boolean) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:115)
Unity.Entities.DefaultWorldInitialization:smile:efaultLazyEditModeInitialize() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:150)
Unity.Entities.GameObjectEntity:Initialize() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities.Hybrid/Components/GameObjectEntity.cs:154)
Unity.Entities.GameObjectEntity:OnEnable() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities.Hybrid/Components/GameObjectEntity.cs:164)

The one with root cause not at GameObjectEntity exist as well

ArgumentException: Unknown Type:`Unity.Scenes.SubScene` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].
Unity.Entities.TypeManager.GetTypeIndex (System.Type type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Types/TypeManager.cs:825)
Unity.Entities.TypeManager.GetTypeIndex[T] () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Types/TypeManager.cs:812)
Unity.Entities.EntityQueryBuilder.ForEach[T0] (Unity.Entities.EntityQueryBuilder+F_C`1[T0] action) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/EntityQueryBuilder_ForEach.gen.cs:175)
Unity.Scenes.Editor.SubSceneLiveLinkSystem.OnUpdate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Scenes.Editor/SubSceneLiveLinkSystem.cs:83)
Unity.Entities.ComponentSystem.InternalUpdate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystem.cs:818)
Unity.Entities.ComponentSystemBase.Update () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystem.cs:287)
Unity.Entities.ComponentSystemGroup.OnUpdate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystemGroup.cs:451)
UnityEngine.Debug:LogException(Exception)
Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Stubs/Unity/Debug.cs:25)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystemGroup.cs:455)
Unity.Entities.ComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystem.cs:818)
Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystem.cs:287)
Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ScriptBehaviourUpdateOrder.cs:135)

Yes, I get the last one Unity.Scenes.SubScene spewing non stop.
Also get non stop NullReferenceExceptions if the Entity Debugger window is open.

I’m not getting these in my project (or empty project with p33). Did you guys try reimport+clear package cache+delete script assemblies?

Only thing I noticed was tests take considerably more time to run in p33. ECS Tests take much longer to run in p33 than p32

Thanks Creepgin, that solved some of my errors.

The Unknown Type error though was because I had IEquatable on a component without also having GetHashCode(). Luckily I remembered this post from aeldron mentioning it not long ago. I only had a single IEquatable component for test purposes so just got rid of it and that removed the spam errors.

1 Like

That seems like you need to clean you package folder like mentioned before.
I did get that error but I’m using IComponentData with generics. And for that I had to create a .cs file with the concrete type declaration.
For a component like this:

public struct MyGenericComponent<T> : IComponentData where T : struct {
  public T Value;
}

And if I use MyGenericComponent and MyGenericComponent somewhere in my code, then I declare them in my AssemblyInfo.cs file:

[assembly: RegisterGenericComponentType(typeof(MyGenericComponent<int>))]
[assembly: RegisterGenericComponentType(typeof(MyGenericComponent<float>))]
2 Likes

Is there anything magic about the AssemblyInfo.cs file, or can you put your assembly attribute basically in any file?

I am trying to solve the same problem, but it won’t work. DOes the AssemblyInfo.cs file need to be registered somewhere or reside in a special location?

AssemblyInfo.cs can go anywhere.

Testing with Entities 0.1.1, Unity 2019.3.0b6, you can declare [RegisterGenericComponentType] in any .cs file - e.g. the same script as your system or component, if you want.

using Unity.Entities;

[assembly: RegisterGenericComponentType(typeof(GenericComponent<int>))]
[assembly: RegisterGenericComponentType(typeof(GenericComponent<float>))]


public struct GenericComponent<T> : IComponentData {
    public int Value;
}
6 Likes

Just for the record, this error also happens when a struct is not explicitly public, and a job attempts to capture it. Even though the compiler can access it, Burst isn’t able to find it.

reimporting all solved these issues for me