Search Unity

Making Monobehaviour as a Component type in ECS

Discussion in 'Entity Component System' started by sexysoup, Feb 14, 2020.

  1. sexysoup

    sexysoup

    Joined:
    Apr 22, 2014
    Posts:
    17
    After learning ECS for some time, I think the biggest usability problem of ECS is actually not so much with the ECS itself, but its interoperability with the current GameObject/Mono structure.
    Have Unity devs considered of making Mono-derived component as some sort of ILegacyComponentData? Put some pointer in it so it runs Awake Start Update FixedUpdate etc on the data. Exclude ILegacyComponentData from all the native containers so it can not be used with the job system.
    Provide some API like GetEntityComponentData in MonoBehaviour and GetMonoBehaviourComponent in EntityManager;
    Deprecate the concept of GameObject and everything references each other with Entity, so everything is unified.
    If game devs wish to optimize their existing projects with ECS, they can gradually take data fields from MB scripts to component data and make systems on them.
    Just some thoughts throwing out there.
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,271
    5argon likes this.
  3. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    This is entityManager.Add/GetComponentObject which you can use mono types (Add doubles as set). Also see entityQuery.ToComponentArray (not ToComponentDataArray). Component object types are all compatible with ComponentType.__ so you can use them in making EntityQuery/Desc.