Search Unity

Following the ECS Sample example works partially only

Discussion in 'Entity Component System' started by madks13, Nov 6, 2019.

  1. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    So I've had to stop using Unity for a few months because life happens.

    Today I pulled on the ECS Samples project and opened Unity. Opened the For Each example and saw there are changes. Most notable being ConvertToEntity.

    Decided to make a new project and see how all the new features work. So I open the HUB, create new 2D project. Make a new scene, create empty object. Add MeshRenderer and MeshFilter. Create new Material and enable GPU Instancing. Add the newly created material to MeshRenderer and choose Quad for MeshFilter. Add ConvertToEntity and launch.

    The player launches the scene, the object is not visible. When I open the Entity Debuger, the entity is created, but only the LocalToWorld, Rotation, and Translation components are on the entity.

    The ECS Sample scene contains a README that says :

    ## Converting from GameObject to Entity

    The **ConvertToEntity** MonoBehaviour converts a GameObject and its children into Entities and ECS Components upon Awake. Currently the set of built-in Unity MonoBehaviours that ConvertToEntity can convert includes the Transform and MeshRenderer. You can use the **Entity Debugger** (menu: **Window** > **Analysis** > **Entity Debugger**) to inspect the ECS Entities and Components created by the conversion.

    You can implement the IConvertGameObjectEntity interface on your own MonoBehaviours to supply a conversion function that ConvertToEntity will use to convert the data stored in the MonoBehaviour to an ECS Component.

    In this example, the **RotationSpeedAuthoring_ForEach** MonoBehaviour uses IConvertGameObjectEntity to add the RotationSpeed_ForEach Component to the Entity on conversion.

    If I read that right, only the ConvertToEntity script on the object to convert should be sufficient, given that a MeshRenderer is present too.

    Am I misunderstanding something here?

    I tested both the ECS Samples scene and my scene with Unity 2019.2.11f, the latest current version, as well as all the latest versions of the packages.

    I also tried with a Cube MeshFilter. Same result.
     
  2. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    Make sure you have the HybridRenderer package installed
     
  3. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    173
    Worked like a charm, thanks. Another new feature discovered :)