hybrid style ECS to render objects ?

Hello, does and one know how to use hybrid style ECS to render the object meshrenderer.

would be very interested to find out if it possible?

I would also like to know if ECS can take care of the physics?

Thanks

Daniel

You turn off the MeshRenderer, then you base your drawing on Graphics.DrawMesh or Graphics.DrawMeshInstanced instead. You can make a system with required data coming from ECS then loop through them to use those commands. In the future, those 2 commands would ideally accept native containers so no copy from ECS out is required. Currently the fast way to copy data out from ECS you can look in MeshInstanceRendererSystem.cs > CopyMatrices.

MeshInstanceRendererComponent together with PositionComponent RotationComponent etc. uses this approach by collecting/processing the matrix required for Graphics.DrawMeshInstanced and finally loop through them in a system. Mesh can go in an ISharedComponentData.

ECS does not support physics right now…

1 Like

Hi, and thanks for the reply. In context of the hybrid system i am currently doing this:

    struct Components
    {
        public Rotator rotator;
        public Transform transform;
        public MeshRenderer renderer;
      
    }
    protected override void OnUpdate()
    {
        foreach (var e in GetEntities<Components>())
        {
            var time = Time.deltaTime;
            e.transform.Rotate(0, e.rotator._speed * time, 0);
            //e.renderer.material.color = e.rotator._color;
        }

    }

How would i implement what you have suggested in this scenario?

here I’ve posted an example with physics and rendering using game objects

ECS part is a pure without using mono-behavior-components on entities

Line 12 should be outside of the loop. It will not change during execution of this loop and you are unnecessarily paying a cost of method call each loop iteration.

Hi Micz, thanks for that reply, yeah was on to that was just seeing if it made a difference :wink: