Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

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! :)