If I have multiple systems and I would like to share data between them. By data I mean for example native containers, global settings etc. I also would like to be able to modify this data by multiple systems.
What would be the best approach.
What about some global services that could be used by multiple Systems.
Pretty common concept and solved with SingletonComponents.
Create an IComp with your NativeContainers. Don’t forget to init and dispose the native containers, best done in the systems OnCreate/OnDestroy.
In a system just call SystemAPI.GetSingleton<T> and send it to your job. You don’t need GetSingletonRW if you don’t read/write on the main thread but you still need to register a write for the system dependency so the job system doesn’t get confused and can schedule your jobs accordingly!
That part is a bit awkward. You can either call GetSingletonRW once in OnCreate so it’s registered or use a custom method, which is most of the times better because it’s easily possible for some cases, that the singleton doesn’t exist yet when you call GetSingletonRW.
So you can call state.AddSystemWriteDependency(TypeManager.GetTypeIndex<T>()); in OnCreate.
As always with entities, this needs internal access and the asmref trick shown here: NZCore/NZCore/Internal at main · enzi/NZCore · GitHub
Yep, not even arguing about it.
I find entities development without internal access near impossible.
DOTS discord is a great place to ask questions, I’ve learned a lot, same for this forum but well, it’s a lot less realtime and dedicated. (hm, I think that’s the wrong word. I don’t mean to downplay any active forum members who’ve helped tremendously. coming more from a personal side as I’m less active here)
My core package has many great things to help with DOTS development. The root readme has an overview of the features, although with very lacking documentation. But imo, it’s more of a, if you need it, you’ll know basis. Most of the stuff in there was for things I already knew the concept of but thought, ah, I’m good, I don’t need it. Well, and then it grew.
If you want something even more advanced, look for tertles core lib. Many great things I have in my own are a distilled version of tertles lib.