Search Unity

Tons of [RegisterGenericComponentType] error on preview 33

Discussion in 'Entity Component System' started by 5argon, May 25, 2019.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I just upgraded and got these errors from Unity's built-in types throwing repeatedly. Anyone with the same issue?

    Screenshot 2019-05-26 00.13.03.png

    The RequestSceneLoaded one for example :

    Code (CSharp):
    1.  
    2. 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].
    3. Unity.Entities.TypeManager.GetTypeIndex (System.Type type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Types/TypeManager.cs:825)
    4. Unity.Entities.TypeManager.GetTypeIndex[T] () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Types/TypeManager.cs:812)
    5. Unity.Entities.ComponentType.ReadWrite[T] () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Types/ComponentType.cs:44)
    6. Unity.Scenes.SubSceneStreamingSystem.OnCreate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Scenes.Hybrid/SubSceneStreamingSystem.cs:68)
    7. Unity.Entities.ComponentSystemBase.CreateInstance (Unity.Entities.World world) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystem.cs:201)
    8. Unity.Entities.World.AddSystem[T] (T system) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/World.cs:341)
    9. 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)
    10. Unity.Entities.World.GetOrCreateSystemInternal (System.Type type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/World.cs:251)
    11. Unity.Entities.World.GetOrCreateSystem (System.Type type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/World.cs:279)
    12. 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)
    13. UnityEngine.Debug:LogException(Exception)
    14. Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Stubs/Unity/Debug.cs:25)
    15. Unity.Entities.DefaultWorldInitialization:GetOrCreateManagerAndLogException(World, Type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:42)
    16. Unity.Entities.DefaultWorldInitialization:Initialize(String, Boolean) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:115)
    17. Unity.Entities.DefaultWorldInitialization:DefaultLazyEditModeInitialize() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:150)
    18. Unity.Entities.GameObjectEntity:Initialize() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities.Hybrid/Components/GameObjectEntity.cs:154)
    19. Unity.Entities.GameObjectEntity:OnEnable() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities.Hybrid/Components/GameObjectEntity.cs:164)
    20.  
    The one with root cause not at GameObjectEntity exist as well


    Code (CSharp):
    1. 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].
    2. Unity.Entities.TypeManager.GetTypeIndex (System.Type type) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Types/TypeManager.cs:825)
    3. Unity.Entities.TypeManager.GetTypeIndex[T] () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Types/TypeManager.cs:812)
    4. 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)
    5. Unity.Scenes.Editor.SubSceneLiveLinkSystem.OnUpdate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Scenes.Editor/SubSceneLiveLinkSystem.cs:83)
    6. Unity.Entities.ComponentSystem.InternalUpdate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystem.cs:818)
    7. Unity.Entities.ComponentSystemBase.Update () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystem.cs:287)
    8. Unity.Entities.ComponentSystemGroup.OnUpdate () (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystemGroup.cs:451)
    9. UnityEngine.Debug:LogException(Exception)
    10. Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/Stubs/Unity/Debug.cs:25)
    11. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystemGroup.cs:455)
    12. Unity.Entities.ComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystem.cs:818)
    13. Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ComponentSystem.cs:287)
    14. Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.33/Unity.Entities/ScriptBehaviourUpdateOrder.cs:135)
    15.  
    16.  
     
  2. JooleanLogic

    JooleanLogic

    Joined:
    Mar 1, 2018
    Posts:
    447
    Yes, I get the last one Unity.Scenes.SubScene spewing non stop.
    Also get non stop NullReferenceExceptions if the Entity Debugger window is open.
     
  3. Singtaa

    Singtaa

    Joined:
    Dec 14, 2010
    Posts:
    492
  4. JooleanLogic

    JooleanLogic

    Joined:
    Mar 1, 2018
    Posts:
    447
    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.
     
    Singtaa likes this.
  5. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    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:
    Code (CSharp):
    1. public struct MyGenericComponent<T> : IComponentData where T : struct {
    2.   public T Value;
    3. }
    And if I use MyGenericComponent<int> and MyGenericComponent<float> somewhere in my code, then I declare them in my AssemblyInfo.cs file:
    Code (CSharp):
    1. [assembly: RegisterGenericComponentType(typeof(MyGenericComponent<int>))]
    2. [assembly: RegisterGenericComponentType(typeof(MyGenericComponent<float>))]
     
    davenirline and Razmot like this.
  6. Arkuni

    Arkuni

    Joined:
    May 30, 2013
    Posts:
    58
    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?
     
    Last edited: Oct 9, 2019
  7. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    AssemblyInfo.cs can go anywhere.
     
  8. Endlord

    Endlord

    Joined:
    Jan 7, 2014
    Posts:
    11
    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.

    Code (CSharp):
    1. using Unity.Entities;
    2.  
    3. [assembly: RegisterGenericComponentType(typeof(GenericComponent<int>))]
    4. [assembly: RegisterGenericComponentType(typeof(GenericComponent<float>))]
    5.  
    6.  
    7. public struct GenericComponent<T> : IComponentData {
    8.     public int Value;
    9. }
     
  9. LudiKha

    LudiKha

    Joined:
    Feb 15, 2014
    Posts:
    140
    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.
     
  10. AdamBebko

    AdamBebko

    Joined:
    Apr 8, 2016
    Posts:
    168
    reimporting all solved these issues for me