Hello,
I have started learning DOTS, and I try to simply display a sprite with the Hybrid Renderer without using Entity conversion.
I have every required package to use ECS, and all is fine when I use MonoBehaviour with a MeshRenderer and a ConvertToEntity component, but when I try to create entities in a pure way, nothing is displayed at screen.
On the Entity Debugger my entity is correctly displayed but nothing is rendered.
Here’s my code:
using Unity.Entities;
using Unity.Rendering;
using Unity.Transforms;
using UnityEngine;
public class GameManager : MonoBehaviour
{
[SerializeField]
private Mesh mesh = null;
[SerializeField]
private Material material = null;
private void Start()
{
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
EntityArchetype entityArchetype = entityManager.CreateArchetype(
typeof(LocalToWorld),
typeof(Translation),
typeof(RenderMesh)
);
Entity entity = entityManager.CreateEntity(entityArchetype);
entityManager.SetSharedComponentData(entity, new RenderMesh
{
mesh = this.mesh,
material = this.material
});
}
}
In my scene I only have a camera (the default one) and a GameObject with the GameManager script on it. The mesh field is a Quad mesh, and the material field is a simple material with shader Unlit/Transparent and a sprite. When I use a MeshRenderer with this mesh and this material all works fine so the problem doesn’t come from them.
I probably made a beginner mistake but I don’t get it. Any help is appreciated Thank you in advance!