I’m currently teaching myself the EntityComponentSystem. However, I want to set up Entity rendering I am am running into multiple issues.
From the documentation, I am gathering that I need to use the RenderMeshUtility in order to be able to add graphics.
However, even though I have downloaded both the Entities and Entities Graphics packages, I am unable to use the RenderMeshUtility or RenderMesh in my code.
It doesn’t show up as a useable class and I can’t find it in the code autofill…
Here’s my code so far, I don’t know if I set it up incorrectly:
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Rendering;
using Unity.Transforms;
using UnityEngine;
using UnityEngine.Rendering;
[GenerateTestsForBurstCompatibility]
public class EntitityManager : MonoBehaviour
{
[SerializeField] Mesh mesh;
[SerializeField] Material material;
private void Start()
{
Unity.Entities.EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity entity = entityManager.CreateEntity(typeof(Level));
entityManager.SetComponentData(entity, new Level { level = 1 });
}
}```
If your code is in a separate assembly, you’ll need to add a reference to Unity.Entities.Graphics in your asmdef.
Note that a more convenient way to create renderable entities is to use subscenes, baking, prefabs, etc. I also see you’re creating entities in a MonoBehaviour script - in ECS it is more natural to place most of your code inside a system.
You can still type the code to see if the issue is just on the IDE side, or if it actually completely refuses to compile for some reason. (It’s possible to encounter occasional desync between Unity and Visual Studio. I’ve had much more luck with Jetbrains Rider regarding issues like these.)
Try:
var test = typeof(Unity.Rendering.RenderMeshUtility);
Does the console show a compilation error when you switch back to Unity?