Search Unity

Entity Debugger feedback

Discussion in 'Entity Component System' started by Daniel_Brauer, Mar 21, 2018.

  1. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    The release of the Entity Component System comes with a debugging view to give you some insight into what's happening in your ECS worlds:

    Screenshot 2018-03-20 18.19.24.png

    The window can be found under Window>Entity Debugger, and has the following features:
    • List all systems in a world. Empty/non-running systems are listed in grey.
    • Systems are sorted alphabetically (EntityManager is always at the top), but are grouped by execution group. Use the UpdateInGroup attribute to group systems and make organising their dependencies easier.
    • Enable/disable systems individually
    • See the approximate time each system spends on the main thread
    • Select a system to list its ComponentGroups
    • Select a ComponentGroup to see all the Entities in it
    • Select an Entity to show its Component data in the Inspector. (This still needs work, but it's already often useful)
    This system-centric view is not something we have had in Unity before. It is not a replacement for scene editing tools, which will come later.

    Once you've had time to play with ECS, I'd love to hear about your experiences. What works, what doesn't, and what would you like to see? It's still early days, and we're quite willing to make drastic changes if we think they'll help more people make great games.

    Thanks,
    Daniel Brauer
     
    tigerleapgorge, twobob, cxode and 4 others like this.
  2. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    347
    So there is a way to see entities already...
    I think instead of "entity 1" it should be name of i.e. archetype of this entity if exist. It will be more transparent if you will see i.e. "player archetype" so you can easily see whats going on.
     
  3. RootCauseProductions

    RootCauseProductions

    Joined:
    Feb 1, 2018
    Posts:
    31
    Entities don't have names, they are just a number.

    For now, you could create a marking component (IComponentData with 0 fields) and a system that uses that marker but does nothing with it. With the current debugger you could find your marking system to list all of the entities that have that marker.
     
    tigerleapgorge and Krajca like this.
  4. RootCauseProductions

    RootCauseProductions

    Joined:
    Feb 1, 2018
    Posts:
    31
    Any chance we can get a view showing the order of execution of the systems soon? I can see this being a pain point.
     
  5. Krajca

    Krajca

    Joined:
    May 6, 2014
    Posts:
    347
    Useful workaround but doesn't it spam debugger with fake systems? I'm still wondering if debugger can check i.e. archetype of entity. You instantiate whole archetype, so it should be possible, isn't it?
     
  6. RootCauseProductions

    RootCauseProductions

    Joined:
    Feb 1, 2018
    Posts:
    31
    ECS doesn't really care what the archetype is, it is just the starting list of components added to the entity. Having the editor track which archetype was used at creation would be a nice feature.

    As for the workaround, I think we will find that any system that is used in only one archetype will work so you really don't need the marker container/system that often. During development I think I will create a Debug group (when needed) to keep these kinds of things in. Not only would that help organize the debugger information but would allow me to schedule it after everything else if I want to do any debug logging.

    As I am gaining understanding of this paradigm I really like the flexibility. It will be incredibly easy to 'whip out' at debugging system specific to your use case using the exact same tools you do for the rest of your application.
     
  7. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    So far Entity Debugger is quite nice that able to observe what entities have been used inside a observed system. The next thing to improve will be:
    1) Make entity able to modify component data at inspector just like modify data at MonoBehaviour when in play mode
    2) Make the view (things can see from scene) spawns at the scene and link with the entity to make it able know that the particular view is corresponding to which entity. It will have the button and when pressing it will jump to the Entity Debugger and auto direct and highlight all the systems that use the entity.
     
    Last edited: Mar 22, 2018
    phobos2077, xontik and laurentlavigne like this.
  8. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    + Entity centric display
     
    twobob likes this.
  9. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    I think this is already kind of implict though just by seeing the name of the system. I mean, it would be a really odd bug if somehow the system grabbed a component that wasn't explicitly intended for it. I dont think that could really even happen.

    So you kind of already know just by selecting the system. I suppose it would make it more explicit, though.
     
  10. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,334
    Sorry for the off-topic, but could you clean that window up soon? It's already three quarters of my screen tall in an empty project, and every new Unity update seems to add another entry. There's also a lot of asset store packages that adds their own entries, and we'd like to have our own windows in there as well. It's getting pretty hard to find things!
     
    rigidbuddy, Havokki and Ofx360 like this.
  11. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    I can agree with that. My current monitor is 1366x768 max resolution and that menu dropdown is well over my screen. It is pretty bloated.
     
  12. Ofx360

    Ofx360

    Joined:
    Apr 30, 2013
    Posts:
    155
    *leans in and whispers* and clean up the Project Window context menu too please. Its getting absurd at this point
     
  13. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Thanks, I've forwarded yours and Ofx360's feedback to the UX team.
     
  14. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Yes, showing execution order and managing dependencies are the goals of the next tool.
     
  15. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    One thing we've considered is automatically adding editor-only components for debugging purposes. One example would be the time that an Entity was created. Names are still tricky, though, as this is not derived information.
     
    twobob likes this.
  16. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    tigerleapgorge likes this.
  17. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    We're working on the ability to write ComponentData from the inspector.
    I'm currently adding a list of Systems/ComponentGroups which contain the selected entity. This will appear at the bottom of the Entity inspector.

    Scene View integration is a bigger topic, but it's something I'd like to add as well.
     
    chrismarch and tigerleapgorge like this.
  18. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Yes, we definitely want to provide a better overview of how systems interact, as well as allowing users to define new constraints or relax existing ones.
     
    tigerleapgorge likes this.
  19. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
  20. RootCauseProductions

    RootCauseProductions

    Joined:
    Feb 1, 2018
    Posts:
    31
    Naming things is the hardest part of programming.

    I like the idea of editor-only components. Ideally, for naming, the developer would write a function or system that sets the name with "Entity ##" as the default. The only problem with using a ComponentSystem is dealing with strings of unknown length.
     
    idbrii likes this.
  21. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    Constraints are code, right? So you're setting up a UI to change the code? That'd be great.
     
  22. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    @Daniel-Brauer, I found another 6 improvements that are quite important.

    1) Display all the systems that haven been created with the correct order without needing to enter play mode.
    2) Entity Debugger has a Entity tab to show all the available entities when entering play mode.
    3) Ability to set time threshold and the system will mark as red when the time taken to execute over the time threshold.
    4) Visualize all the systems in details that will tell whether it's update or fixed update system, group of systems (parent system and sub system), ComponentSystem, JobComponentSystem, order of systems, sync point and etc.
    5) Add search input field into Entity Debugger that able to search specific system or entity and filter out redundant system or entity based on keyword.
    6) Entity Debugger has a Memory Layout tab that visualize the memory layout of entities to make it easier to setup archetype.
     
    echeg, Krajca, laurentlavigne and 2 others like this.
  23. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    And also double click on a system opens the c# file at the right line
     
    Krajca and optimise like this.
  24. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    No code generation yet. This would be viewing constraints defined in code, and making changes on top of those.
     
  25. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    The window only displays systems that exist. At the moment, I think mixing in systems that have existed would overcomplicate the UI.
    The EntityManager of a World always contains all Entities. It is at the top of the System list.
    Can you tell me more about the workflow you'd like to support? On the face of it, finding a specific entity by typing sounds like it could be tricky.
    These are good ideas, but probably better better addressed with separate tools. I've taken note of them.
     
  26. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    Ok, no idea how this will work together so you got me curious!
     
  27. YuriyVotintsev

    YuriyVotintsev

    Joined:
    Jun 11, 2013
    Posts:
    93
    How about adding optional "EntityNameComponent" to Entity? If this component is on Entity, then in EntityDebugger entity shows with this name, else it has "Entity #" name. And sort entities by name. (Entities without name goes after entities with name).
     
    FROS7 and laurentlavigne like this.
  28. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Will it really to make it overcomplicate the UI that make it works in non-play mode? Instead of display systems of Editor World,

    it will directly display Default World and any other actual World


    It's just like the search bar at Profiler that it will filter out things for you when u type keyword. For example, u type Position2D, PlayerInput space Position2D, Health, Enemy then other systems will be filter out and left only EntityManager, EnemyShootSystem and EnemyRemovalSystem.





    One more thing I forget is to visualize parallel systems.
     
  29. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Worlds can be created and destroyed, Systems can be added and removed, ComponentGroups can be added, and Entities can be created and destroyed. When your game isn't running, what version of the runtime data would you want to inspect, and why?
     
  30. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    I would like to see is only all the initial systems that you will see when u just hit play mode. So,no Entities and only systems will be displayed. Of course, if able to set execution order of systems in one center place instead of setting individual system with attribute then I think this feature is not really require anymore.
     
  31. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Last edited: Apr 4, 2018
  32. StephanK

    StephanK

    Joined:
    Jul 10, 2012
    Posts:
    47
    As some people already mentioned I would really like to be able to inspect and maybe change the ComponentData for a specific entity. Also the current way of listing systems and showing their used ComponentGroups and the entities within that group is quite useful. If I could now select that entity and get a list of ComponentData (ideally editable) that would be very handy.
     
  33. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    The Reactive System I expect is:

    It will have a place to setup what ComponentData u wish to react to. For this example code, if there is Sprite Component add/replace to the entity, it will enter this system.

    Code (CSharp):
    1. protected override ICollector<GameEntity> GetTrigger(IContext<GameEntity> context)
    2.  
    3.    {
    4.  
    5.        return context.CreateCollector(GameMatcher.Sprite);
    6.  
    7.    }
    Then it will further check whether the entity has sprite component and does not have view component.

    Code (CSharp):
    1. protected override bool Filter(GameEntity entity)
    2.  
    3.    {
    4.  
    5.        return entity.hasSprite && !entity.hasView;
    6.  
    7.    }
    If everything meets the requirement, it will execute the system code.

    Code (CSharp):
    1. protected override void Execute(List<GameEntity> entities)
    2.  
    3.    {
    4.  
    5.        foreach (GameEntity e in entities)
    6.  
    7.        {
    8.  
    9.            GameObject go = new GameObject("Game View");
    10.  
    11.            go.transform.SetParent(_viewContainer, false);
    12.  
    13.            e.AddView(go);
    14.  
    15.            go.Link(e, _context);
    16.  
    17.        }
    18.  
    19.    }
     
  34. StephanK

    StephanK

    Joined:
    Jul 10, 2012
    Posts:
    47
    That looks a lot like entitas. In Unity's scenario I would expect something like a [ChangedOnly] attribute that will inject only entities whose data has changed. So for instance the TransformUpdateSystem could do something like this:

    Code (CSharp):
    1. public struct Group
    2.     {
    3.         [ChangedOnly] public ComponentDataArray<Position> positions;
    4.         public ComponentDataArray<TransformMatrix> matrices;
    5.     }
    And then receive only entities that have both a TransformMatrix and a Position where the Position was changed.
     
  35. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Can we try and keep this particular thread about the EntityDebugger window? ;)
     
  36. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    It's not editable yet, but you're aware you can already see ComponentData for a selected Entity in the Inspector?
     
  37. StephanK

    StephanK

    Joined:
    Jul 10, 2012
    Posts:
    47
    No, i wasn't aware of that. Will check tonight. I thought I was only able to see entities/archetypes per system. Hm let me guess i can make the window even wider and will see what i wanted?
     
  38. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Nope, it shows up in the actual inspector! See the right-hand portion of the screenshot in the original post.
     
  39. StephanK

    StephanK

    Joined:
    Jul 10, 2012
    Posts:
    47
    Ah damn. At home I'm limited to my Macbook's screen estate so in my layout i actually was tabbing between inspector and entity debugger window.... :D
     
  40. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    That's good feedback too...
     
  41. StephanK

    StephanK

    Joined:
    Jul 10, 2012
    Posts:
    47
    Wouldn't be so much of a problem if I would have known that. :) THe hierarchy view is pretty useless anyway when doing pure ecs. Ideally this could all be somehow displayed in the hierarchy anyway. Otherwise I imagine it's going to be a bit weird when dealing with complex transform hierarchies (which we will still have).
     
    laurentlavigne likes this.
  42. SubPixelPerfect

    SubPixelPerfect

    Joined:
    Oct 14, 2015
    Posts:
    224
    1) ability to tweak systems order
    2) ability to tweak components values
    3) ability to tweak components list
    4) ability to save current entity state
    a. at edit time to entity-asset file
    b. to serialize current entity state at run-time
    5) ability to tweak saved entity-asset file
    6) ability to load entity-asset to ECS
    7) ability to do the rest myself - i'd like to have an option to extend entity manager and entity debugger
    8) +1 for [ChangedOnly]
     
  43. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    1) After I tried ECS for some time, I think the best approach to group systems and setup order of systems is to make it able to set at Entity Debugger directly. The way to change the order of system can design it like Reorderable List Editor API that u can drag up and down to change the order.

    2) Entity Debugger seems like not able to update enum data properly as it keeps the same value even the data has been changed. There are also a lot of data not able to visualize properly. I guess the feature is not completed yet.

    3) It will be nice if EntityManager System at Entity Debugger has the same grouping same type components feature like other systems.

    4) Able to record all the changes in Entity Debugger just like Profiler does so you are able to inspect all the changes has been made. I think it will even better if combine it with Profiler so u can inspect the changes of Entity Debugger with the data at Profiler together but it needs to figure out how to visualize the data.
     
    Last edited: Apr 11, 2018
  44. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    After tried ECS for some time, I think make it both Game Object and Entity at Entity Debugger sync together seamlessly. Meaning that when u for example add a Damage ComponentData to the entity, u can see the data of Damage ComponentData at both Entity Debugger and Game Object inspector. Currently you only can sync the components attached at Game Object to entity at Entity Debugger.

    From what I know, in future the current Game Object will be replaced to Entity but it will still support legacy Monobehaviour. I guess it will become something that I expect.
     
    Last edited: Apr 13, 2018
  45. The5

    The5

    Joined:
    May 26, 2017
    Posts:
    19
    Information for the highlighted Entity is currently only displayed when the inspector panel is in "normal" mode.
    Would be nice to have that info in debug mode too.

    Also, it could be useful to be able to see the different instances/variations that exist for a given ISharedComponentData.
     
    Last edited: May 20, 2018
  46. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    One important things to finding bugs is the order of system activation, how that plays out in a given frame.

    Currently Profiler timeline mode is an excellent tool for that, but things could be more streamlined if you integrate that information with Entity Debugger. In Profiler the issue is that I have to zoom in very close to see all the system names, and slowly scrolls and click to check each system name from left to right. If we have a tab which list system activation order from top to bottom line by line in Entity Debugger that would be very useful.
     
  47. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    How about color-coding the systems and entities with an attribute? naming certain archetypes or entities that have certain components and displaying entities by name?
     
    recursive likes this.
  48. Xerioz

    Xerioz

    Joined:
    Aug 13, 2013
    Posts:
    104
    Giving system names/labels and the ability to view it as a tree, would be nice to have.
    Instead of having, PlayerThis, PlayerThat, BulletThis, BulletThat, we could for instance give them labels like Player/This, Player/That, Bullet/This, Bullet/That and the list would be displayed like the hierarchy editor.
     
  49. nope-ee

    nope-ee

    Joined:
    Jun 8, 2018
    Posts:
    6
    Hello.

    I just stumbled upon issue with Entity Debugger.
    Shared Components exposed incorrectly in it.
    Specifically they don't initialized with related value.

    Here is example:
    Code (CSharp):
    1. public class ExampleSystem : JobComponentSystem {
    2.     struct DataComponent : ISharedComponentData {
    3.         public int id;
    4.     }
    5.     protected override void OnCreateManager(int capacity) {
    6.         var entityManager = World.Active.GetOrCreateManager<EntityManager>();
    7.         var entity        = entityManager.CreateEntity();
    8.         entityManager.AddSharedComponentData(entity, new DataComponent{id = 13});
    9.     }
    10. }
    Result: Value in Inspector did non match to actual.
    Actual value of a component is fine, I checked this.


    UPD: in thread, which I initially created, also noted that sometimes Component Data may be also displayed incorrectly.
     
    Last edited: Jun 9, 2018
  50. jj_unity328

    jj_unity328

    Joined:
    Jun 7, 2018
    Posts:
    22
    I've been wondering what data is displayed/serialized in the Entity Debugger (I noticed it's a `ScriptableObject`, probably with a custom Editor on it) or if it would support `[System.Serializable]`.

    I noticed that the `MonoBehaviour` I gave it doesn't display at all, making it a little harder to debug.