Hey everyone, I’m prototyping a grand strategy game to familiarize myself with ECS. At the end of every turn, I want a group of systems to simulate elements of my population. I followed some tutorials and made a system that listens for a button press via tags. Now I’ve come across two issues:
1. Using burst compile gives me an error: "
…\ProtoPopGrowthSystem.cs(13,9): Burst error BC1025: Accessing the type ProtoPopCalTag (e.g. using typeof) is not supported" Is there a way to rectify a UI button press to be more friendly with burst/ECS?
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
if(query.IsEmptyIgnoreFilter)
return;
var job = new ProtoPopGrowthJob{};
job.ScheduleParallel();
state.EntityManager.RemoveComponent<ProtoPopCalTag>(query);
}
}
2. I’d like to retrieve the total population from my entities and display it on TMP text in world space. I was setting up each entity to have its own canvas and text, but I noticed that the canvases can’t reference a camera outside of the sub-scene (as shown in the image below). Now I’m lost on trying to bridge the entity to UI gap. Any help would be appreciated.
You need to show full code, as the error message does not seem to correlate to the code you have shown.
You have to wire it up at runtime. I think most people just use Camera.main to get the camera. I use a cross-scene GUID solution for connecting subscene entities with scene GameObjects.
Use QueryBuilder on line 13. The way you are doing it now is not Burst-compatible. Or just remove the [BurstCompile] on OnCreate if you don’t care that much on startup performance.
Also, I am looking at your framework for working with DOTS. Looks amazing. Is your GUID solution contained in that package? This solution sounds like it’ll help with more than just connecting UI.