The learning curve is not insignificant. I have been working with ECS for 6 months now and I’m still struggling. I’m a hobbyist, so a lot of the ECS code and examples are hard to understand. Having said that, once you see what it is that they are trying to do and you embrace their concepts and philosophies, then you can really do some amazing things. What took me 10 seconds to build with Gameobjects is currently being done in under 30 ms with entities, jobs, and burst. My project is extremely data-heavy and requires hundred of thousands of entities, but it simply wouldn’t be possible in the GO world.
To answer some of your specific questions.
Where do i define when a System should be active?
-Create a systems folder and use tags (tags aren’t technically required but i find they are very easy to use and give you more control over your filtering). If a system finds the appropriate tag or element that you filtered for then it will run that frame, if it doesn’t see anything then it won’t run. So create an element (either “pure” by instantiating if you can, or through the conversion workflow) and attach a tag to it then create a system file and filter for it. I tend to add data to my tags but it isn’t necessary.
public struct BuildIrisTag : IComponentData
{
public FixedString32 Ticker;
public BlobAssetReference<DateBlobs> Dates;
}
Then do something like this to find the elements that have this tag and run a system on it:
protected override unsafe void OnUpdate()
{
Entities.WithAll<BuildIrisTag>().ForEach((Entity entity, in BuildIrisTag buildIrisTag, in Iris iris) =>
{
// put all your system code here - if you want to run the system every frame then leave the tag in place, if you only want to run the system once, then add this:
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.RemoveComponent<BuildIrisTag>(entity);
}).WithStructuralChanges().WithoutBurst().Run();
}
Put some effort into learning how to run systems with Entities.ForEach and with queries. Using Entities.ForEach | Entities | 0.17.0-preview.42
Using an EntityQuery to query data | Entities | 0.17.0-preview.42
Where do i define the Order of the Systems?
You can control the order of systems using square brackets before the system class declaration. You can also create custom orders if you need to control things closely.
[UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]
public class Build : SystemBase ...
https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/system_update_order.html
It is my understanding that i can do those 2 questions in some sort of Singleton Gamemaster Gameobject. Is this correct? But wouldn’t that mean that i violate Pure ECS by having Gameobjects ?
I have finally been able to get rid of the singleton pattern by fully embracing the tag and system methodology. I don’t know if this will work for you but it is so nice not having to figure out how to pass everything to the singleton to get things done.
Finally, understanding the concepts of ECS and actually implementing them in the way that you want is not an easy task. As I said earlier, my project is data-heavy so I have had to put a ton of effort into reorganizing how the data is handled, (mostly flattening arrays since ECS doesn’t do nested arrays). Learning the job system and how to optimize things will give you incredible speed gains. I had to start measuring things in microseconds because it was being run so fast!!
It will take you several months to link everything together, but once you do, you’ll have a hard time going back to GO. Just my opinion.