Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved How to Debug.Log human-readable component-types of entity in DOTS Runtime?

Discussion in 'Project Tiny' started by JonasMumm, Mar 17, 2020.

  1. JonasMumm

    JonasMumm

    Joined:
    Feb 22, 2019
    Posts:
    23
    Greetings!
    Since as of now the EntityDebugger can't be connected to DOTS Runtime builds, I'm having a hard time debugging a rendering related part of my project since the DOTS Runtime rendering differs from the Editor rendering so greatly. Specifically I'd like to know what kinds of Components are on an entity of mine, after the Conversion Systems have run, but I can't find a way to get human-readable Names for the components on an entity.
    The closest I've gotten is this:
    Code (CSharp):
    1. var chunk = EntityManager.GetChunk(myEntity);
    2. var componentTypesArray = chunk.Archetype.GetComponentTypes();
    3.  
    4. for (var i = 0; i < componentTypesArray.Length; i++)
    5. {
    6.      var componentType = componentTypesArray[i];
    7.  
    8.      var typeName=componentType.ToString();
    9.  
    10.      Debug.Log(typeName);
    11. }
    The ToString() Method seems to actually be properly implemented specifically for ComponentType, so I'd expect it to return useable results, but it only returns strings of digits instead of the type name, like these:
    413972085225235610
    4936923425435084526
    13950328305391848973

    Is there any way to identify the kinds of components on the entity from these strings?

    Alternatively, could there be a way to view the result of the GameObjectConversion when converting for a DOTS Runtime build?
     
  2. kevinmv

    kevinmv

    Unity Technologies

    Joined:
    Nov 15, 2018
    Posts:
    51
    Hey hey!

    You can lookup the name for component types from the TypeManager.TypeInfo type:
    Code (CSharp):
    1.  
    2. TypeManager.GetTypeInfo<MyComponent>().Debug.TypeName;
    3. TypeManager.GetTypeInfo(myTypeIndex).Debug.TypeName;
    4.  
    Please note that this debug information is stripped from release builds so you will only get meaningful strings in debug/develop builds.

    Hope this helps!
    Kev
     
    JonasMumm likes this.
  3. JonasMumm

    JonasMumm

    Joined:
    Feb 22, 2019
    Posts:
    23
    Exactly what I was looking for, thanks a bunch! :)
     
  4. kevinmv

    kevinmv

    Unity Technologies

    Joined:
    Nov 15, 2018
    Posts:
    51
    No problemo! :)