Search Unity

Making Monobehaviour as a Component type in ECS

Discussion in 'Data Oriented Technology Stack' started by sexysoup, Feb 14, 2020 at 3:03 AM.

  1. sexysoup

    sexysoup

    Joined:
    Apr 22, 2014
    Posts:
    2
    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:
    805
    5argon likes this.
  3. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,482
    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.
     
unityunity