Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Hybrid ECS, ignore some MonoBehaviours

Discussion in 'Entity Component System' started by Justin_Larrabee, Nov 19, 2018.

  1. Justin_Larrabee

    Justin_Larrabee

    Joined:
    Apr 24, 2018
    Posts:
    106
    Right now the hybrid ECS system in GameObjectEntity, as far as I can tell, is gathering every component on a GameObject. I have some MonoBehaviours that have nothing to do with the ECS system and I do not plan on accessing from within systems. I'm not sure if this is causing additional overhead, but it is breaking the entity debugger horribly for me.

    Is there an attribute I can place on a MonoBehaviour to prevent it's introspection by the ECS system?
     
  2. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    969
    A GameObject will only be filtered in ECS systems if you added a GameObjectEntity component on them. Your issue only happens if you're adding this component to every GameObject you have.
     
  3. JustinLarrabee

    JustinLarrabee

    Joined:
    Feb 3, 2013
    Posts:
    13
    That's not my problem. The GameObjects that I am using a GameObjectEntity on contain N components, of which M are ComponentDataWrappers. In the entity debugger when I select the entity on that GameObject I am seeing the full N components/monobehaviours, where I would ideally only see the components used by the ECS.
     
  4. I don't think it's possible but you can write your own system and you can ignore whatever components you wish.
     
  5. JustinLarrabee

    JustinLarrabee

    Joined:
    Feb 3, 2013
    Posts:
    13
    I guess this is a failure to communicate what I mean. Here is a screenshot of a chunk for one of my entities that is tied to a GameObject via a GameObjectEntity:



    The best example here are the SelectionBaseMarker and KinematicCharacterMotor MonoBehaviours. Both of these are not meant to be used within the ECS system and thus there should be some way to exclude them so a) they don't influence chunk selection or chunk size and b) they do not show up in the Entity Debugger.
     
  6. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    The "introspection" is just gameObject.GetComponent<Component>(), so that will include everything. You will have to hack GameObjectEntity.cs if you want to exclude something via attributes..
     
  7. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    Yep as @5argon says - just change GameObjectEntity in package folder, this functionallity exists in GameObjectEntity, you just must use you "withLegacy" bool in this place, or change it to "false" by default
    upload_2018-11-21_14-8-49.png
     
  8. JustinLarrabee

    JustinLarrabee

    Joined:
    Feb 3, 2013
    Posts:
    13
    Yea I guess I had hoped this was something built in and not something I'd need to hack in the package itself (which I then would need to redo each package update and on each checkout of the repo).